Search code examples
macoscocoakeyautomatic-ref-countingnsarraycontroller

A strong key is changed by add: in NSArrayController. Why?


If an NSArrayController is bound to an array that is generated using

@synthesize (strong) anArray;

very strange things happen when using the add: or remove: bindings. For example, I end up with a different address for anArray. I am sure this has to do with the strong keyword. Can someone explain to me why this happens?


Solution

  • Are you binding the NSArrayController to an NSArray, or an NSMutableArray? NSArrayController with work if you bind it to an NSArray, but because the array is immutable the array controller will create a new array every time you add or remove objects.