0

In my project, I have an NSArrayController bound to save to a the application's standard defaults (NSUserDefaults). This in itself works perfectly - objects added are saved and restored as expected.

However, if I programmatically modify one of the NSMutableDictionaries contained in the NSArrayController's array, none of the changes are saved. Only values set with the creation of the dictionary seem to stick.

I suspect this is because simply calling setObject:forValue: on the dictionaries in the array doesn't notify the controller of changes, but I'm not sure. Am I doing something wrong?

UPDATE: I have since switched from NSMutableDictionary to a custom object that conforms to KVC (to the best of my knowledge - I'm using properties so that should be taken care of) as well as NSCoding. It can and does save and restore fine - it's just not consistent. It kinda saves whenever it feels like it instead of when I update a property.

John Wells
  • 1,139
  • 1
  • 10
  • 27
  • Is there a reason you're not using a User Defaults controller? And are you using [arrayController willChangeValueForKey:@""] before modifying your object, then using [arrayController didChangeValueForKey:@""] right after? – macandyp May 30 '13 at 17:54
  • I'm using user defaults because it seems to make sense in this case - the array is simply a list of the user's downloads. Also, while I was not using will/didchangevalueforkey, that should no longer be necessary - please see the updated original post. – John Wells May 30 '13 at 18:42

1 Answers1

0

Well, I ended up just writing my own controller responsible for loading and saving downloads to their own plist file. It saves when it's told to without fail, so the problem is solved.

John Wells
  • 1,139
  • 1
  • 10
  • 27