开发者

How do I access the correct NSManagedObjectContext from Mogenerator generated human files?

I'm trying to follow the directions in the top answer to this question and I'm getting an error trying to access the moc variable. I know that it's supposed to be a managed object context, 开发者_开发技巧but I can't seem to figure out how to get access to it.

The file that I'm adding the -awakeFromInsert code is the "human" file generated by running mogenerator v1.22. I have a feeling that mogenerator populates some property with the correct managed object context but that it's not called moc. I could be totally off-base though so feel free to school me!


Mogenerator does not add a method named moc. It's simply making subclasses of NSManagedObjects that contain accessors for convenience. Since they subclasses of NSManagedObject you can use the -managedObjectContext method to access the context that the object is associated with. So changing your -moc calls to -managedObjectContext should do the trick.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜