开发者

Objective C, Core Data issue

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. 开发者_如何学C

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


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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜