I've the following relationship:
Playlist may have one-to-many songs, and Song may belong to one-to-many playlists.
My problem consists in getting the order of a song in a specific playlist - for example,
In addition, the order of the songs within a playlist can be changed as they are listed in a tableview.
I now want to keep track of the orders.
I've tried the following approaches:
Both approaches seem to be very error-prone - in addition I constantly get a warning such as "'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release".
Is there a better and more sophisticated approach storing and retrieving a Song's order within different playlists?
In the properties of your songs
relationship in the Playlist
entity in the Data Model, tick the "Ordered" checkbox. Instead of NSSet
, they will be available as NSOrderedSet
then.