Skip to content

Commit dcaf958

Browse files
author
ljh
committed
code clean & bug fix
1 parent ad8e81e commit dcaf958

File tree

6 files changed

+42
-45
lines changed

6 files changed

+42
-45
lines changed

LKDBHelper/Helper/LKDB+Mapping.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,27 @@
3939
@interface LKDBProperty : NSObject
4040

4141
///保存的方式
42-
@property (readonly, copy, nonatomic) NSString* type;
42+
@property (nonatomic, copy, readonly) NSString* type;
4343

4444
///保存到数据的 列名
45-
@property (readonly, copy, nonatomic) NSString* sqlColumnName;
45+
@property (nonatomic, copy, readonly) NSString* sqlColumnName;
4646
///保存到数据的类型
47-
@property (readonly, copy, nonatomic) NSString* sqlColumnType;
47+
@property (nonatomic, copy, readonly) NSString* sqlColumnType;
4848

4949
///属性名
50-
@property (readonly, copy, nonatomic) NSString* propertyName;
50+
@property (nonatomic, copy, readonly) NSString* propertyName;
5151
///属性的类型
52-
@property (readonly, copy, nonatomic) NSString* propertyType;
52+
@property (nonatomic, copy, readonly) NSString* propertyType;
5353

5454
///属性的Protocol
5555
//@property(readonly,copy,nonatomic)NSString* propertyProtocol;
5656

5757
///creating table's column
58-
@property BOOL isUnique;
59-
@property BOOL isNotNull;
60-
@property (copy, nonatomic) NSString* defaultValue;
61-
@property (copy, nonatomic) NSString* checkValue;
62-
@property NSInteger length;
58+
@property (nonatomic, assign) BOOL isUnique;
59+
@property (nonatomic, assign) BOOL isNotNull;
60+
@property (nonatomic, copy) NSString* defaultValue;
61+
@property (nonatomic, copy) NSString* checkValue;
62+
@property (nonatomic, assign) NSInteger length;
6363

6464
- (BOOL)isUserCalculate;
6565
@end
@@ -68,8 +68,8 @@
6868

6969
- (id)initWithKeyMapping:(NSDictionary*)keyMapping propertyNames:(NSArray*)propertyNames propertyType:(NSArray*)propertyType primaryKeys:(NSArray*)primaryKeys;
7070

71-
@property (readonly, nonatomic) NSUInteger count;
72-
@property (readonly, nonatomic) NSArray* primaryKeys;
71+
@property (nonatomic, readonly) NSUInteger count;
72+
@property (nonatomic, readonly) NSArray* primaryKeys;
7373

7474
- (LKDBProperty*)objectWithIndex:(NSInteger)index;
7575
- (LKDBProperty*)objectWithPropertyName:(NSString*)propertyName;

LKDBHelper/Helper/LKDB+Mapping.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ - (void)updateProperty:(LKDBProperty*)property propertyName:(NSString*)propertyN
2323

2424
#pragma mark - 声明属性
2525
@interface LKDBProperty ()
26-
@property (copy, nonatomic) NSString* type;
26+
@property (nonatomic, copy) NSString* type;
2727

28-
@property (copy, nonatomic) NSString* sqlColumnName;
29-
@property (copy, nonatomic) NSString* sqlColumnType;
28+
@property (nonatomic, copy) NSString* sqlColumnName;
29+
@property (nonatomic, copy) NSString* sqlColumnType;
3030

31-
@property (copy, nonatomic) NSString* propertyName;
32-
@property (copy, nonatomic) NSString* propertyType;
31+
@property (nonatomic, copy) NSString* propertyName;
32+
@property (nonatomic, copy) NSString* propertyType;
3333

3434
- (id)initWithType:(NSString*)type cname:(NSString*)cname ctype:(NSString*)ctype pname:(NSString*)pname ptype:(NSString*)ptype;
3535
@end

LKDBHelper/Helper/LKDBHelper.m

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,15 @@ - (void)setDb_inserting:(BOOL)db_inserting;
4444
@end
4545

4646
@interface LKDBWeakObject : NSObject
47-
@property (LKDBWeak, nonatomic) LKDBHelper* obj;
47+
@property (nonatomic, LKDBWeak) LKDBHelper* obj;
4848
@end
4949

5050
@interface LKDBHelper ()
51-
52-
@property (strong, nonatomic) NSMutableArray* createdTableNames;
53-
54-
@property (LKDBWeak, nonatomic) FMDatabase* usingdb;
55-
@property (strong, nonatomic) FMDatabaseQueue* bindingQueue;
56-
@property (copy, nonatomic) NSString* dbPath;
57-
58-
@property (strong, nonatomic) NSRecursiveLock* threadLock;
51+
@property (nonatomic, LKDBWeak) FMDatabase* usingdb;
52+
@property (nonatomic, strong) FMDatabaseQueue* bindingQueue;
53+
@property (nonatomic, copy) NSString* dbPath;
54+
@property (nonatomic, strong) NSMutableArray* createdTableNames;
55+
@property (nonatomic, strong) NSRecursiveLock* threadLock;
5956
@end
6057

6158
@implementation LKDBHelper
@@ -204,13 +201,12 @@ - (void)setDBPath:(NSString*)filePath
204201
withIntermediateDirectories:YES
205202
attributes:attributes
206203
error:&error];
207-
208204
if (success == NO) {
209205
LKErrorLog(@"create dir error: %@", error.debugDescription);
210206
}
211207
}
212208
else {
213-
/**
209+
/**
214210
* @brief Disk I/O error when device is locked
215211
* https://github.com/ccgus/fmdb/issues/262
216212
*/
@@ -226,19 +222,19 @@ - (void)setDBPath:(NSString*)filePath
226222

227223
self.dbPath = filePath;
228224
[self.bindingQueue close];
225+
[self.createdTableNames removeAllObjects];
229226

230227
#ifndef SQLITE_OPEN_FILEPROTECTION_NONE
231228
#define SQLITE_OPEN_FILEPROTECTION_NONE 0x00400000
232229
#endif
233-
234230
self.bindingQueue = [[FMDatabaseQueue alloc] initWithPath:filePath
235231
flags:SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FILEPROTECTION_NONE];
236232
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
237233
if ([fileManager fileExistsAtPath:filePath]) {
238234
[fileManager setAttributes:@{ NSFileProtectionKey : NSFileProtectionNone } ofItemAtPath:filePath error:nil];
239235
}
240236
#endif
241-
237+
242238
///reset encryptionKey
243239
_encryptionKey = nil;
244240

@@ -263,6 +259,7 @@ - (void)executeDB:(void (^)(FMDatabase* db))block
263259
else {
264260
if (self.bindingQueue == nil) {
265261
self.bindingQueue = [[FMDatabaseQueue alloc] initWithPath:_dbPath];
262+
[self.createdTableNames removeAllObjects];
266263
[self.bindingQueue inDatabase:^(FMDatabase* db) {
267264
db.logsErrors = LKDBLogErrorEnable;
268265
if (_encryptionKey.length > 0) {

LKDBHelper/Helper/LKDBUtils.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,22 @@ extern NSString* LKSQLTypeFromObjcType(NSString* objcType);
9595
@interface LKDBQueryParams : NSObject
9696

9797
///columns or array
98-
@property (strong, nonatomic) NSString* columns;
99-
@property (strong, nonatomic) NSArray* columnArray;
98+
@property (nonatomic, copy) NSString* columns;
99+
@property (nonatomic, copy) NSArray* columnArray;
100100

101-
@property (strong, nonatomic) NSString* tableName;
101+
@property (nonatomic, copy) NSString* tableName;
102102

103103
///where or dic
104-
@property (strong, nonatomic) NSString* where;
105-
@property (strong, nonatomic) NSDictionary* whereDic;
104+
@property (nonatomic, copy) NSString* where;
105+
@property (nonatomic, copy) NSDictionary* whereDic;
106106

107-
@property (strong, nonatomic) NSString* groupBy;
108-
@property (strong, nonatomic) NSString* orderBy;
107+
@property (nonatomic, copy) NSString* groupBy;
108+
@property (nonatomic, copy) NSString* orderBy;
109109

110-
@property (assign, nonatomic) NSInteger offset;
111-
@property (assign, nonatomic) NSInteger count;
110+
@property (nonatomic, assign) NSInteger offset;
111+
@property (nonatomic, assign) NSInteger count;
112112

113-
@property (assign, nonatomic) Class toClass;
113+
@property (nonatomic, assign) Class toClass;
114114

115-
@property (copy, nonatomic) void (^callback)(NSMutableArray* results);
115+
@property (nonatomic, copy) void (^callback)(NSMutableArray* results);
116116
@end

LKDBHelper/Helper/LKDBUtils.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import "LKDBUtils.h"
1010

1111
@interface LKDateFormatter : NSDateFormatter
12-
@property (strong, nonatomic) NSRecursiveLock* lock;
12+
@property (nonatomic, strong) NSRecursiveLock* lock;
1313
@end
1414

1515
@implementation LKDateFormatter

LKDBHelper/Helper/NSObject+LKModel.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@
2626
/**
2727
* if you set it will use it as a table name
2828
*/
29-
@property (copy, nonatomic) NSString* db_tableName;
29+
@property (nonatomic, copy) NSString* db_tableName;
3030

3131
/**
3232
* the model is inserting ..
3333
*/
34-
@property (readonly, nonatomic) BOOL db_inserting;
34+
@property (nonatomic, readonly) BOOL db_inserting;
3535

3636
/**
3737
* sqlite comes with rowid
3838
*/
39-
@property NSInteger rowid;
39+
@property (nonatomic, assign) NSInteger rowid;
4040

4141
/**
4242
* overwrite in your models, if your table has primary key

0 commit comments

Comments
 (0)