I have two core data entities: Category
and Music
.
Category
has a toMany
relationship.
Music
has a toOne
relationship.
Each entity display their values on separate tables.
Tables are populated by independent NSArrayControllers
.
I select a category on its table.
I create a new Music
by this line on the code on MusicArrayController
:
let newAttribute = self.newObject() as! Music
newAttribute.label = "New Music"
self.addObject(newAttribute)
If after that, that I check the last category I have selected, I see this new object is already in the category's toMany NSSet
.
Example:
toMany
NSSet
.I have not added any code to do that assignment.
Is this Core Data normal behavior?
The array controller shows and manages the Music
objects of the Category
. When a Music
object is added with self.addObject(newAttribute)
then the array controller adds the Music
object to the relationship. This is normal NSArrayController
behaviour, with and without Core Data.