Are there any NSUserDefaults keys which aren't valid?
Are there any NSUserDefaults keys which aren't valid?
- Subject: Are there any NSUserDefaults keys which aren't valid?
- From: Jonathan del Strother <email@hidden>
- Date: Thu, 26 Jan 2006 17:57:33 +0000
I have an NSDictionary with a bunch of MP3 file dates, keyed by the
artist & album of the corresponding MP3.
I'm storing this dictionary in NSUserDefaults.
For me, this works fine, but I'm seeing a bunch of crash reports from
users, looking like the following :
Thread 1 Crashed:
0 com.apple.CoreFoundation 0x90740ba4 CFRetain + 60
1 com.apple.CoreFoundation 0x90751fa4 CFDictionarySetValue +
448
2 com.apple.CoreFoundation 0x9078f32c writeXMLValue + 272
3 com.apple.CoreFoundation 0x9079cd98
_CFApplicationPreferencesSet + 212
4 com.apple.Foundation 0x928f2fa0 -[NSUserDefaults
setObject:forKey:] + 108
The code prompting this crash is :
NSMutableDictionary* newFileDates = [[[NSUserDefaults
standardUserDefaults] objectForKey:@"File Dates"] mutableCopy];
[newFileDates setObject:fileDate forKey:albumKey];
[[NSUserDefaults standardUserDefaults] setObject:newFileDates
forKey:@"File Dates"];
So, this takes the existing date structure from NSUserDefaults, adds
a new NSDate to it (with a key that typically looks something like
"Nirvana - Nevermind"), then saves the updated date structure back to
NSUserDefaults. At this point, some people are seeing crashes.
The only potential problem I can see, is if someone has an mp3 with
'interesting' characters in the album field ("%@", for example),
whether that might do something funny when it's stored in
NSUserDefaults. Or, given I've managed to construct an NSString with
those characters, should NSUserDefaults be able to handle anything
that gets sent to it?
Any thoughts? Sorry for the vague question...
Jon
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden