【发布时间】:2017-05-20 16:10:29
【问题描述】:
我想知道为什么我的 Core Data 停止保存更改。事实上,上面的代码在几个小时前就已经工作了。当我尝试打印错误时,它会打印(null)。下面的代码是NSManagedObjectSubclass的自定义方法:
-(void)bindWithModel:(MenuAPIModel*)model{
self.basketId = [model.basketId integerValue];
self.coreId = [model.itemId integerValue];
self.name = [model name];
self.orderId = [model.orderId integerValue];
self.payedFrom = [model payedFrom];
self.persons = [model persons];
self.price = [model.price integerValue];
self.price3 = [model.price3 integerValue];
self.price12 = [model.price12 integerValue];
self.status = [model status];
[[NSManagedObjectContext MR_defaultContext] MR_saveOnlySelfWithCompletion:^(BOOL contextDidSave, NSError * _Nullable error) {
NSLog(@"error %@", error.localizedDescription);
}];
错误为空,contextDidSave 为 YES。但是当我尝试访问实体时,它会打印 null,并且 SQL 表是空的。为什么?
【问题讨论】:
标签: ios core-data magicalrecord