Re: NSUserDefaults not sticking
Re: NSUserDefaults not sticking
- Subject: Re: NSUserDefaults not sticking
- From: "Rick C." <email@hidden>
- Date: Wed, 10 Sep 2014 13:43:57 +0800
Thanks for the help. So I have double-checked and the info in question that is not sticking is NSString/NSData being written:
[[NSUserDefaults standardUserDefaults] setObject:stringObject forKey:@“MyStringKey”];
[[NSUserDefaults standardUserDefaults] setObject:dataObject forKey:@“MyDataKey”];
Then being read:
NSString *myStringObject = [[NSUserDefaults standardUserDefaults] stringForKey:@“MyStringKey"];
NSData *myDataObject = [[NSUserDefaults standardUserDefaults] dataForKey:@“MyDataKey”];
I am not manipulating my .plist in any other way only using NSUserDefaults. I am aware of the caching issues that started in Mavericks, but if we can’t read/write using NSUserDefaults how else can we do it? Also, when I say not sticking this could be from day to day so I would expect the cache to be updated in that amount of time. What else can I do here or what am I doing wrong???
On Sep 9, 2014, at 2:08 PM, Graham Cox <email@hidden> wrote:
>
> On 9 Sep 2014, at 3:36 pm, Rick C. <email@hidden> wrote:
>
>> I write some data to my .plist using standard NSUserDefaults
>
>
> Are you writing the .plist file, or are you using the NSUserDefaults object exclusively? From 10.9 the .plist isn't updated by NSUserDefaults, so values there can be very much out of date, because the defaults system caches its contents.
>
> You can't rely on the plist being an accurate representation of what the user defaults actually contains.
>
> --Graham
>
>
_______________________________________________
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