0
我正在使用以下核心數據保存代碼,它不保存。 managedObjectContext由提供新上下文的工廠類傳遞。保存在覈心數據不起作用
- (void)save{
NSError *error = nil;
// save the data in context
if ([managedObjectContext hasChanges]) {
if ([managedObjectContext save:&error]) {
if (error) {
DEBUGLOG(@"%@ saving faild with error code: %ld and message: %@", NSStringFromClass([self class]), (long)error.code, error.localizedDescription);
}
else{
DEBUGLOG(@"%@ managedObjectContext save success!!!!!!!!", NSStringFromClass([self class]));
// succesufuly saved data
[self updateLastSuccessSyncGet];
}
}
else{
DEBUGLOG(@"%@ managedObjectContext save failed!!!!!!!!", NSStringFromClass([self class]));
DEBUGLOG(@"%@ saving failed with error code: %ld and message: %@", NSStringFromClass([self class]), (long)error.code, error.localizedDescription);
}
}
}
是[managedObjetContext save:]是否返回錯誤? [managedObjectContext hasChanges]是否應該不返回NO?你是否檢查確保managedObjectContext不是零?我需要更多的細節。 – Jpoliachik 2014-09-01 15:26:47