ayController绑定到NSManagedObjectCo

ayController绑定到NSManagedObjectCo

本文介绍了如何使用MagicalRecord时将NSArrayController绑定到NSManagedObjectContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ive最近开始将一个项目迁移到MagicalRecord,无法找到我如何将它绑定到一个NSArrayController在XCode 4的界面生成器。



(除了大量的google)引用[MagicalRecord defaultContext]和绑定,但我得到一个错误:无法执行操作没有受管对象上下文


解决方案

确保按注释中提到的方法打开MagicalRecord。您还必须在您的应用程式委托中建立公开由MagicalRecord提供的预设管理物件上下文的资源:

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



这是为了绑定有东西保存...虽然我' ve没有在那种情况下使用它自己。让我知道结果如何。


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.

解决方案

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.

这篇关于如何使用MagicalRecord时将NSArrayController绑定到NSManagedObjectContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 14:13