I wonder why my Core Data stop to save changes. In fact, code above worked hours ago. When i try to print out an error, it print (null)
. Code below is custom method for 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);
}];
Error is null and contextDidSave
is YES. But when i try to access entity it prints null, and SQL table is an empty. Why?
I assume that
bindWithModel
method is inNSManagedObject
subclass. If so, then you should usemanagedObjectContext
property from this class rather thenMR_defaultContext
:Previously it was working probably because context from
[NSManagedObjectContext MR_defaultContext]
was the same asself.managedObjectContext
.