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?
精彩评论