简体   繁体   中英

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 "!" 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). An NSTextField is present, whose Value I want to bind to the NSObjectController...and this is where the problem comes in.

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 :

奇怪的自动填充候选人的屏幕截图

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:

错误的屏幕截图

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM