如何将NSTextField的值绑定到NSObjectController的内容没有错误? [英] How do I bind an NSTextField's value to an NSObjectController's content without errors?

查看:309
本文介绍了如何将NSTextField的值绑定到NSObjectController的内容没有错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很简单的设置在这里,Xcode给我一个无评论的红色!

I have a pretty simple set up here, and Xcode is giving me a comment-less red "!" mark in the interface builder.

从基于Core Data的文档模板开始。文档xib有一个NSObjectController实例,其受管对象上下文绑定到文件的所有者(我的NSPersistentDocument子类)。一个NSTextField是存在的,其值我想绑定到NSObjectController ...这是问题所在。

Started from a Core Data-based document template. The document xib has an NSObjectController instance, whose Managed Object Context is bound to the File's Owner (my NSPersistentDocument subclass). An NSTextField is present, whose Value I want to bind to the NSObjectController...and this is where the problem comes in.

我键入标题为模型Key Path,因为这是我的NSManagedObject的正确属性,它应该出现在文本字段中。当我点击空的Controller Key字段时,自动完成建议仅用于 NSArrayController 的字段:

I type "title" for the "Model Key Path," because that's the correct property for my NSManagedObject, which should appear in the text field. When I click into the empty Controller Key field, the autocompletion bizarrely suggests fields that are only for NSArrayController:

每次尝试键入content作为控制器键(因为这是NSObjectController的正确属性),然后点击Tab / Return /无论什么,content被移动到模型键路径,如下:

Any time I try to type "content" as the Controller Key (because that's the correct property for an NSObjectController) and then hit Tab/Return/whatever, the "content" is shifted down to the Model Key Path, like so:

这是红色感叹号?当我离开控制器键空和模型键路径作为content.title,该应用程序工作。绑定是正确的,反映了我的NSManagedObject的title属性。我绝对确定对象控制器是NSObjectController的一个实例。

What is this red exclamation mark for? When I leave "Controller Key" empty and "Model Key Path" as content.title, the app works. The binding is correct and reflects the "title" property of my NSManagedObject. I am absolutely sure that "Object Controller" is an instance of NSObjectController.

推荐答案

使用选择。对于 NSObjectController ,选择是内容对象。

Use "selection". For an NSObjectController, the selection is the content object.

这篇关于如何将NSTextField的值绑定到NSObjectController的内容没有错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆