How to copy a song from the iPod library to your application?

I do not want to select n again the same sound as the background in the application. How can I copy a sound file to an application that is assigned to folders / files? I can play the file in the mediaPicker method: didPickMediaItems: How to save this sound file?

+1
source share
1 answer

MPMediaItem and MPMediaItemCollection support NSCoding , so you can serialize it and save it using NSKeyedArchiver , see the documentation . If obj is any object that supports NSCoding ,

  NSData*data=[NSKeyedArchiver archivedDataWithRootObject:obj]; 

converts it to an instance of NSData . Or you can get the permanent identifier of the MPMediaItemPropertyPersistentID song

  NSNumber*persistentID=[mediaItem valueForProperty:MPMediaItemPropertyPersistentID]; 

and then yo ucan save persistentID somewhere, like NSUserDefaults .

+1
source

All Articles