views:

255

answers:

2

I'm following a tutorial in "More iPhone 3 Development. In the code, they have a line: NSManagedObjectContext *managedObjectContext = appDelegate.managedObjectContext;

I get an error: "accessing unknown 'managedObjectContext' getter method" on that line.

I've downloaded his sample code and his program runs fine with that line of code. I've tried rewriting the code and I've even copied and pasted his code into my program, but I still get the error.

I am using the newest SDK, and I'm wondering if something might have changed so this getter method doesn't work anymore, but I do not get any warning about deprecation.

Does anyone know what is going on, or better yet, a better way to write this line and not get the error.

Thanks LadyDev

+1  A: 

When you create a core data project there's a method that is automatically created for you...

- (NSManagedObjectContext *) managedObjectContext

That's your AppDelegate's getter method for the managed object context. Also in the header file you will see that getter method defined:

@property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;

So make sure you AppDelegate has these then you should not have that problem.

regulus6633
You also have to #import the AppDelegate's header file for the compiler to recognize `.managedObjectContext` as the appropriate @property accessor.
Barry Wark
A: 

I had the same problem, i found that when I created the project it put 3 @property declarations in the SuperDBAppDelegate.m file which may be a new way of doing it i'm not quite sure. Anyway I took it from there and put it in the .h file and that fixed the error, however now I have other issues which I am still debugging but hopefully that works for you.

Justin