开发者

saving managedObjectContext returns null error

开发者 https://www.devze.com 2023-04-04 07:14 出处:网络
Could anyone see any possible reasons why? Friend *newFriend = [NSEntityDescription insertNewObjectForEntityForName:@\"Friend\" inManagedObjectContext:managedObjectContext];

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

精彩评论

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

关注公众号