【发布时间】:2012-04-05 02:11:03
【问题描述】:
我正在使用 Core Data 将一些信息保存在 SQLite 数据库中。我正在使用模拟器进行测试,并使用 sqlite3 查询数据库并验证我存储的内容是否符合预期。
我看到的是数据在我保存后的 15-20 秒后才会出现在 SQLite 数据库中。
这是我保存的代码:
NSEntityDescription *customerType = [NSEntityDescription entityForName:@"CustomerType" inManagedObjectContext:context];
CustomerType *ct = [[CustomerType alloc]initWithEntity:customerType insertIntoManagedObjectContext:context ];
ct.code = code;
NSError* error = nil;
if (![context save:&error] || error)
NSLog(@"Saved new customer (error=%@)", [error debugDescription]);
保存操作成功完成。
关于我为什么会看到这种延迟的任何提示?是我的保存操作没有正常运行,还是延迟保存数据是模拟器造成的?
【问题讨论】:
-
以后,如果您的问题与 objc 开发有关,请务必将您的问题标记为
Objective-C,因为它告诉 StackOverflow 如何突出显示发布的代码。 -
@Andrew:请从您的解决方案中创建一个答案,然后接受它。目前,问题似乎没有答案,这将使与您有相同问题的人更难搜索答案。
-
抱歉——有点生锈了。完成!
标签: objective-c ios sqlite core-data