开发者

How to Create & Add an Core-Data Object to an Existing Object Having an Optional To-One Relationship?

开发者 https://www.devze.com 2023-03-23 17:01 出处:网络
I cannot find any information anywhere (google, cocoadev, developer.apple) about managing an optional to-one relationship with core data and cocoa bindings with the exception of using a pop-up box. Us

I cannot find any information anywhere (google, cocoadev, developer.apple) about managing an optional to-one relationship with core data and cocoa bindings with the exception of using a pop-up box. Using a pop-up box assumes the optional object already exists, but that's not how I want the process to work. I want to be able be able to select an existing object (User) in the table view and click an add button which would then cr开发者_如何学Goeate an new entity (Account) and assign the relationship to the selected User. In my model not all Users have an Account, and an Account is never created without having a User first.

Any ideas on how to do this?

I have tried to create a NSArrayController with the following:

Bind to: UserController Controller Key:selection Model Key Path: Account

I then bound a button to the -add function. When I do this I get:

[NSCFSet managedObjectContext]: unrecognized selector sent to instance 0x1001adea0

Please help I have spent days trying to figure this out.


I have learned that you must do this with code. I have extended NSArrayController and overridden the newObject method to assign selected object of other controllers.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号