问题
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