开发者

warning: '-managedObjectContext' not found in protocol(s)

I'm using the following code to reach the MOC in my second view controller

if (managedObjectContext == nil) 
    { 
开发者_如何学编程        managedObjectContext = [[[UIApplication sharedApplication] delegate] managedObjectContext];
    } 

I got the above error and I don't know how to get rid of it!


if (managedObjectContext == nil) 
{ 
    YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
    managedObjectContext = [appDelegate managedObjectContext];
} 

When doing this, the compiler/Xcode knows your [[UIApplication sharedApplication] delegate] is an instance of YourAppDelegate, so it knows it has the managedObjectContext property.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜