NSUserDefaults not saving properly

NSUserDefaults might not have a chance to save depending on how the process is terminated.

This answer has more info: Why is NSUserDefaults not saving my values?


Just in case someone runs accross this: When storing an NSDictionary or NSArray (or mutable Objects of both of them) in the user defaults and they have an NSURL Object stored, it won't save the data on synchonize!


Somewhere you have something like:

// load the default values for the user defaults
userDefaultsValuesPath=[[NSBundle mainBundle] pathForResource:@"UserDefaults" ofType:@"plist"];
userDefaultsValuesDict=[NSDictionary dictionaryWithContentsOfFile:userDefaultsValuesPath];

// set them in the standard user defaults
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict];

If the initial defaults you are setting up do not have LevelFive defaults, then the calls would fail.

Check the return value from -synchronize for errors.