NSUserDefaults and mutability
NSUserDefaults and mutability
- Subject: NSUserDefaults and mutability
- From: Trygve Inda <email@hidden>
- Date: Sat, 08 Mar 2008 21:57:39 +0000
- Thread-topic: NSUserDefaults and mutability
NSUserDefaults docs say: "Values returned from NSUserDefaults are immutable"
However...
NSDictionary * dict = [[NSUserDefaults standardUserDefaults]
persistentDomainForName: @"com.mycompany.myapp"];
// dict is indeed immutable and contains one key value pair subDict which is
// another dictionary. subDict IS mutable
So after doing:
NSDictionary * subDict = [dict objectForKey: @"mySubDict"];
[subDict setValue:someValue forKey:someKey];
[[NSUserDefaults standardUserDefaults] setPersistentDomain:dict forName:@"
com.mycompany.myapp"];
[[NSUserDefaults standardUserDefaults] synchronize];
The item mySubDict within subDict within dict in com.mycompany.myapp
IS changed.
Is this expected? Can I rely on it? I will never need to change dict, but I
am modifying items within a known sub Dictionary.
Thanks
Trygve
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden