开发者

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

开发者 https://www.devze.com 2023-01-07 20:00 出处:网络
I\'m using the following code to reach the MOC in my second view controller if (managedObjectContext == nil)

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

精彩评论

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