I have an NSTableView in a floating window that gets dynamically bound to the arrangedObjects
property of an instance of an NSArrayController that corresponds to the frontmost document window with code like the following:
NSArrayController *documentSpecificArrayController; // properly set elsewhere
NSTableColumn *tableColumnToBind; // properly set elsewhere
[tableColumnToBind unbind:NSValueBinding];
[tableColumnToBind bind:NSValueBinding
toObject:documentSpecificArrayController
withKeyPath:@"arrangedObjects"
options:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],
NSContinuouslyUpdatesValueBindingOption,
nil]];
As long as the represented array/the table view are empty, things work fine; all of the various operations on the table view/represented array within one document work fine. If one switches from a document with a non-empty represented array to a document for which the represented array is empty, an endless stream of *** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)
exceptions are thrown.
Am I missing something that I need to do in cleanly severing the binding when switching windows? Something else? (Is there some specific information that I've omitted that would help diagnose my error?)