1

Anybody know how to do this? The standard method will not work. I want the user to pick a song, and then have it save for the next time they load the app, but i can't seem to get it into NSUserDefaults.

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178
Andrew
  • 15,935
  • 28
  • 121
  • 203

1 Answers1

1

You need to iterate the collection to get the MPMediaItems. MPMediaItem inherits from MPMediaEntity, which has a -valueForProperty: method. If you pass that method the MPMediaItemPropertyPersistentID constant, you'll get back an NSNumber that uniquely identifies the item. This is a value that's persistable across launches.

Community
  • 1
  • 1
Dave DeLong
  • 242,470
  • 58
  • 448
  • 498
  • Hey Dave, I'm getting back null when I ask for the MPMediaItemPropertyPersistentID on my MPMediaItemCollection using valueForProperty. I get back "0" if I use valueForKey. Any ideas? – aaronium112 May 12 '11 at 23:58
  • @MakingScienceFictionFact MPMediaItemPropertyPersistentID is only for MPMediaItems as the name suggests, not MPMediaItemCollections – pnizzle May 20 '13 at 05:39