Difference between "[context save:&error]" and "[appDelegate saveContext]"
I am currently writing an app that is using Core Data and reading up on i开发者_运维知识库t in Apple's documentation. I realize that when I created a window-based app in Xcode 4 it automatically added an instance method:
-(void)saveContext;
But in the examples "around town" (most tutorials) I always see people using:
[context save:&error];
What are the different cases for using one over the other?
that isn't a class method, it is an instance method
[context save:&error]let's you check for an error and handle it explicitlythere better be an
if()around that call tosave:(i.e. don't just checkerror)presumably,
saveContextis intended to be a higher level operation that handles/presents the error internally. It probably callssave:.
加载中,请稍侯......
精彩评论