开发者

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 explicitly

  • there better be an if() around that call to save: (i.e. don't just check error)

  • presumably, saveContext is intended to be a higher level operation that handles/presents the error internally. It probably calls save:.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜