Reputation: 4033
I have been struggling with Core Data sigh so I decided to work this this Apple Core Data tutorial. I am at the point in the tutorial where it asks me to build the project I have put together so far. So I am presently right here in the tutorial. When I am building the project I am getting the following error:
Type of property 'managedObjectContext' ('NSManagedObjectContext *') does not match type of ivar 'managedObjectContext' ('MSManagedObject *__strong')
RootViewController.m
Ivar is declared here
That's what I am getting in error window.
Here are what my files look like,
RootViewController.h http://pastie.org/4111206
RootViewController.m http://pastie.org/4111216
AppDelegate.h http://pastie.org/4111222
AppDelegate.m http://pastie.org/4111227
Upvotes: 0
Views: 189
Reputation: 35384
The error message is explaining it already. You have an ivar managedObjectContext of class NSManagedObject (thats your mistake).
The compiler can't synthesize the property managedObjectContext because you have an ivar of the same name, but different class.
Rename the ivar and change the synthesize line:
@synthesize managedObjectContext = _managedObjectContext;
Upvotes: 0
Reputation: 8808
Your ivar is declared incorrectly. In RootViewController.h,
NSManagedObject *managedObjectContext;
should be written, as the error complains,
NSManagedObjectContext *managedObjectContext;
And actually, with the modern run-time, for quite a while it's been unnecessary (and usually ill-advised) to explicitly declare backing ivars for @synthesize
'd properties. So you can just delete the ivar line entirely and let the compiler make an ivar for you.
Upvotes: 1