Get Track by persistent ID
While the framework always assume i want a track by its index id, this is wrong when trying to do persistent tasks. meaning, If a track is removed or added the index is changed and therefor i cannot assume the track is at the same index.
This is a problem if i try to save last played track index to NSUserDefaults and retrieve it when i get back to the application. it can return a different track or crash if i'm out of bounds.
I understand the use of index for quick scrolling through tracks but there should also be a way to retrieve a track by its persistent id.
Nononononoooo.... getTrackByIndex: is the same as NSArray's objectAtIndex: method. It's not the (non-persistent) ID of the track, just it's place in the music library. A simple ordinal number. However, persistent ID getters can be implemented if you want. Otherwise, you shouldn't make assumptions of the track's non-public properties, title, artist, album, filesystem path etc. should be used instead. Or you can use libgpod directly avoiding this library (which is not meant to be for very complex tasks; it wanted to provide a simple interface to simple tasks).
That's what i said. :) For more persistent use, there must be a 'getTrackByPersistentID:'.
i guess the first line with "i want a track by its index id," is confusing, it should be "i want a track by its index,".
OK, sorry, I misunderstood your question... I'll implement it then. :)