Core Data, NSArrayController and remove:

  • Hi All,

    I'm working on my first Core Data app, so please bear with me!  I've
    run into something that took me quite by surprise, and although I
    assume this is how things work with Core Data I'm not sure I
    understand why.

    I've modeled two entities: AudioStream and Playlist.  Each has an
    optional, to-many relationship called playlists and streams,
    respectively.  Using IB I've created two tables in a view, one for
    displaying streams and one for displaying playlists.  As a next step,
    I created add and remove buttons for adding and removing streams to
    playlists.  Add has some custom logic but remove I initially wired to
    the NSArrayController's remove: selector.

    Here is what caught me off guard:
    When displaying streams for a given playlist, and the remove button
    is clicked, the streams relationship (of the Playlist entity) is
    modified- the AudioStream object is removed- but the playlists
    relationship (of the AudioStream entity) remains unchanged.  It seems
    the array controller is only invalidating half of the relationship.
    I'm not sure why this is happening; the code
      playlistSet  = [streamObject mutableSetValueForKey:@"playlists"];
      [playlistSet removeObject:playlistObject];
    modifies both the playlists and inverse streams relationship.

    Is there some property I should be setting on the NSArrayController
    to have it modify both relationships?

previous month october 2006 next month
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today