On 10 Sep 2014, at 3:43 pm, Rick C. <rickcort...@gmail.com> wrote:

> 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


That should definitely work.

Are you certain something else somewhere isn't using the same key to change the 
setting? Is it possible that the object passed to -setObject:forKey: isn't a 
NSString or NSData? The named getter methods also check the type - does it work 
if you use -objectForKey: instead? Try logging the objects, it's probably 
something you didn't expect.


> Are you calling synchronise too when you're writing?

That isn't needed. It used to flush the defaults to disk but it no longer does 
anything AFAIK. It was never needed within a single app session, and was 
invoked automatically on quit.

--Graham



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to