The setup:
CoreData Model
Product Entity
- Attribute "name"
- Relationship "common" <---> CommonData
CommonData Entity
- Attribute "product_id"
- Relationship "product" <---> Product Entity
View Setup:
- I have a NSTableView to display the product entities and it is bound to an NSArrayController
- There are two buttons "+" and "-" bound to
add:
andremove:
to the respective actions of the NSArrayController. - There is an NSObject controller bound to the
selection.common
content object, with a NSTextView bound to the NSObjectController.
In the Cocoa documentation, it states that the Releationship Entity is not automatically create when, in this case, the product entity is allocated. I can see this behavior when I click the "+" button. The product is added to the NSTableView, but the NSTextView displays "No Context". And, if I create the product and common entities in code, I can see NSTextView display the *product_id* correctly.
I would like to be able to keep the buttons bound to the NSArrayController.
The Question:
- Is there any way to detect that the new product entity has been created?
- What is the best way to add the relationship entity when the new product entity is created via a button action?