[英]How do I bind an NSTextField's value to an NSObjectController's content without errors?
I have a pretty simple set up here, and Xcode is giving me a comment-less red "!" 我在这里有一个非常简单的设置,Xcode给了我一个没有评论的红色“!” mark in the interface builder.
在界面构建器中标记。
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).
文档xib有一个NSObjectController实例,其托管对象上下文绑定到文件的所有者(我的NSPersistentDocument子类)。 An NSTextField is present, whose Value I want to bind to the NSObjectController...and this is where the problem comes in.
存在NSTextField,其值我想绑定到NSObjectController ......这就是问题所在。
I type "title" for the "Model Key Path," because that's the correct property for my NSManagedObject, which should appear in the text field. 我为“模型键路径”键入“title”,因为这是我的NSManagedObject的正确属性,它应出现在文本字段中。 When I click into the empty Controller Key field, the autocompletion bizarrely suggests fields that are only for NSArrayController :
当我点击空的Controller Key字段时,autocompletion奇怪地建议仅用于NSArrayController的字段:
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”作为Controller Key(因为这是NSObjectController的正确属性)然后点击Tab / Return / what时,“content”会向下移动到Model Key Path,如下所示:
What is this red exclamation mark for? 这个红色感叹号是什么? When I leave "Controller Key" empty and "Model Key Path" as content.title, the app works.
当我将“Controller Key”留空并且“Model Key Path”作为content.title时,应用程序正常工作。 The binding is correct and reflects the "title" property of my NSManagedObject.
绑定是正确的,并反映了我的NSManagedObject的“title”属性。 I am absolutely sure that "Object Controller" is an instance of NSObjectController.
我绝对相信“对象控制器”是NSObjectController的一个实例。
Use "selection". 使用“选择”。 For an
NSObjectController
, the selection is the content object. 对于
NSObjectController
,选择是内容对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.