Skip to content

Commit 971e4e2

Browse files
author
li6185377
committed
fix demo bug
1 parent 50ec0f0 commit 971e4e2

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

LKDBHelper/LKAppDelegate.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,8 @@ -(void)test
5252
{
5353
addText(@"示例 开始 example start \n\n");
5454

55-
NSString* dbpath = [NSHomeDirectory() stringByAppendingPathComponent:@"asd/asd.db"];
5655
//清空数据库
57-
// LKDBHelper* globalHelper = [LKDBHelper getUsingLKDBHelper];
58-
59-
LKDBHelper* globalHelper = [[LKDBHelper alloc]initWithDBPath:dbpath];
56+
LKDBHelper* globalHelper = [LKTest getUsingLKDBHelper];
6057
[globalHelper dropAllTable];
6158

6259
//创建表 会根据表的版本号 来判断具体的操作 . create table need to manually call

LKDBHelper/LKTestModels.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ +(void)initialize
3737
//[[self getUsingLKDBHelper] createTableWithModelClass:self];
3838
}
3939

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+
4053
// 将要插入数据库
4154
+(BOOL)dbWillInsert:(NSObject *)entity
4255
{
@@ -148,6 +161,10 @@ +(LKTableUpdateType)tableUpdateForOldVersion:(int)oldVersion newVersion:(int)new
148161

149162

150163
@implementation LKTestForeign
164+
+(LKDBHelper *)getUsingLKDBHelper
165+
{
166+
return [LKTest getUsingLKDBHelper];
167+
}
151168
+(NSString *)getPrimaryKey
152169
{
153170
return @"addid";

0 commit comments

Comments
 (0)