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