I have an NSObjectController called objectController with content bound to locationDictionary. @property (strong) NSMutableDictionary *locationDictionary;
And an NSArrayController called arrayController which has its content bound to objectController.myArrayKey. This array contains column-dictionaries. And an NSTableView (non View-based) whose columns are bound to arrayController. The keys in the column-dictionaries of course correspond to the identifiers of the columns and each element in objectController.myArrayKey represents one row. locationDictionary is set from standardUserDefaults NSDictionary *a = [ standardUserDefaults dictionaryForKey: kToolbarLocations ]; NSDictionary *b = a[ someIdentifier]; self.locationDictionary = b; But when editing the tableView this (sometimes, not always) crashed. So I changed the last line to: self.locationDictionary = [b mutableCopy]; This worked better, but still the occasional crash: "Mutating message sent to immutable object"; the message being: setObject:forKey: (obviously trying to change one of my column-dictionaries) So I changed the line again to: self.locationDictionary = [b veryDeepMutableCopy]; which converts NSArrays to mutable, and the elements thereof into mutable dictionaries. Now I don't see any crashes anymore. Two questions: 1. Is there a better way to do this (letting NSControllers change the stuff to mutable automagically)? 2. Why did this even occasionally work before I made my veryDeepMutableCopy? NSUserDefaults tells me about dictionaryForKey: "The returned dictionary and its contents are immutable, even if the values you originally set were mutable." Does this really mean: "The returned dictionary and its contents are mutable or immutable depending on our whims. You better not rely on their mutability state." Gerriet. _______________________________________________ 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