Re: NSUserDefaults not sticking
Re: NSUserDefaults not sticking
- Subject: Re: NSUserDefaults not sticking
- From: Diederik Meijer | Ten Horses <email@hidden>
- Date: Wed, 10 Sep 2014 07:52:22 +0200
Are you calling synchronise too when you're writing?
[[NSUserDefault standardUserDefaults] synchronise]
Verstuurd vanaf mijn iPhone
> Op 10 sep. 2014 om 07:43 heeft "Rick C." <email@hidden> het volgende geschreven:
>
> 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
_______________________________________________
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