File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -52,11 +52,8 @@ -(void)test
52
52
{
53
53
addText (@" 示例 开始 example start \n\n " );
54
54
55
- NSString * dbpath = [NSHomeDirectory () stringByAppendingPathComponent: @" asd/asd.db" ];
56
55
// 清空数据库
57
- // LKDBHelper* globalHelper = [LKDBHelper getUsingLKDBHelper];
58
-
59
- LKDBHelper* globalHelper = [[LKDBHelper alloc ]initWithDBPath:dbpath];
56
+ LKDBHelper* globalHelper = [LKTest getUsingLKDBHelper ];
60
57
[globalHelper dropAllTable ];
61
58
62
59
// 创建表 会根据表的版本号 来判断具体的操作 . create table need to manually call
Original file line number Diff line number Diff line change @@ -37,6 +37,19 @@ +(void)initialize
37
37
// [[self getUsingLKDBHelper] createTableWithModelClass:self];
38
38
}
39
39
40
+ // 重载可以选择 使用的LKDBHelper
41
+ +(LKDBHelper *)getUsingLKDBHelper
42
+ {
43
+ static LKDBHelper* db;
44
+ static dispatch_once_t onceToken;
45
+ dispatch_once (&onceToken, ^{
46
+ NSString * dbpath = [NSHomeDirectory () stringByAppendingPathComponent: @" asd/asd.db" ];
47
+ db = [[LKDBHelper alloc ]initWithDBPath:dbpath];
48
+ });
49
+ return db;
50
+ }
51
+
52
+
40
53
// 将要插入数据库
41
54
+(BOOL )dbWillInsert : (NSObject *)entity
42
55
{
@@ -148,6 +161,10 @@ +(LKTableUpdateType)tableUpdateForOldVersion:(int)oldVersion newVersion:(int)new
148
161
149
162
150
163
@implementation LKTestForeign
164
+ +(LKDBHelper *)getUsingLKDBHelper
165
+ {
166
+ return [LKTest getUsingLKDBHelper ];
167
+ }
151
168
+(NSString *)getPrimaryKey
152
169
{
153
170
return @" addid" ;
You can’t perform that action at this time.
0 commit comments