How to bind NSArrayController to NSManagedObjectContext when using MagicalRecord

血红的双手。 提交于 2019-12-08 03:17:33

问题


Ive recently started migrating a project to MagicalRecord and cant find how i would bind it to an NSArrayController in the interface builder of XCode 4.

The approach ive taken so far (besides lots of google) is making a reference to the [MagicalRecord defaultContext] and binding to that but i get an error: "Cannot perform operation without a managed object context"

Any pointers in the right direction would be really appreciated.


回答1:


Make sure you turn on MagicalRecord as mentioned in the comment. You may also have to make a property in your app delegate that exposes the default managed object context provided by MagicalRecord:

- (NSManagedObjectContext *) applicationContext;
{
    return [NSManagedObjectContext MR_defaultContext];
}

This is so that binding has something to hold onto...though I've not used it in that scenario myself. Let me know how it turns out.



来源:https://stackoverflow.com/questions/11059896/how-to-bind-nsarraycontroller-to-nsmanagedobjectcontext-when-using-magicalrecord

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!