开发者

saving managedObjectContext returns null error

Could anyone see any possible reasons why?

Friend *newFriend = [NSEntityDescription insertNewObjectForEntityForName:@"Friend" inManagedObjectContext:managedObjectContext];
newFriend.name = @"Jim";
newFriend.age = [NSNumber numberWithInt:5];

NSError *error = nil;
if ([managedObjectContext save:&error]) 
{
     NSLog(@"error %@", error); 
}

managedObjectContext was passed to the开发者_运维技巧 view controller where this code is from the application delegate.

Thanks


 if (![managedObjectContext save:&error])
 {
     NSLog(@"error %@", error);
 }

that should be


You should expect error to continue to be nil if save: succeeded (and therefore returned YES as you're testing). What behavior did you expect here?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜