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:
- I select Rock and Roll in the category table.
- Table 2 show the musics under that category.
- I add a new music.
- The Rock and Roll category has already that new music listed on its
toManyNSSet.
I have not added any code to do that assignment.
Is this Core Data normal behavior?
The array controller shows and manages the
Musicobjects of theCategory. When aMusicobject is added withself.addObject(newAttribute)then the array controller adds theMusicobject to the relationship. This is normalNSArrayControllerbehaviour, with and without Core Data.