I refer to the Previous post for storing the NSURL iPod library in NSUserDefault. But it is not saved in NSUserDefault after closing the application.
I use other NSStrings to store in NSUserDefaults, which is fine, but when I store NSUrl as an absolute string .. it does not save the value.
What could be the reason?
EDIT
The following code that I use to store the value of NSUserDefault:
currentItem = [collection.items objectAtIndex:songCount];
songURL = [currentItem valueForProperty:MPMediaItemPropertyAssetURL];
[[NSUserDefaults standardUserDefaults] setObject:[currentItem valueForProperty:MPMediaItemPropertyTitle] forKey:@"songTitle"];
[[NSUserDefaults standardUserDefaults] setObject:[songURL absoluteString] forKey:@"songURL"];
avPlayer = [[AVPlayer alloc] initWithURL:songURL];
NSLog(@"songTitle: %@ songURL : %@",[[NSUserDefaults standardUserDefaults]objectForKey:@"songTitle"], songURL);
The following error occurs when I try to save NSURL:
2011-09-13 18:47:23.258 Tabata Timer[933:707] songURL : ipod-library://item/item.mp3?id=-3715406019015217536
2011-09-13 18:47:23.258 Tabata Timer[933:707] *** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value 'ipod-library://item/item.mp3?id=-3715406019015217536' of class 'NSURL'.
2011-09-13 18:47:23.260 Tabata Timer[933:707] songTitle : Ghajini
2011-09-13 18:47:24.860 Tabata Timer[933:707] *** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value 'ipod-library://item/item.mp3?id=-3715406019015217536' of class 'NSURL'.
2011-09-13 18:47:24.963 Tabata Timer[933:707] songURL : ipod-library://item/item.mp3?id=-3715406019015217536
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.5 (8L1)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
source
share