NSBrowser Not Usable with NSTreeController
It seemed so simple. Just create a tree using NSTreeNode objects, bind an NSTreeController to it, and bind an NSBrowser to the controller. See Below: [treeController bind:@"contentArray" toObject:self withKeyPath:@"rootArray" options:nil];
[browser bind:@"content" toObject:treeController withKeyPath:@"arrangedObjects" options:nil]; [browser bind:@"contentValues" toObject:treeController withKeyPath:@"arrangedObjects.representedObject" options:nil];
NSLog(@"browser: %@", browser);Alas it is not meant to be. The NSBrowser object will inevitable cause a crash by infinitely recursing like so:...
#19 0x94c9d48d in -[NSView setKeyboardFocusRingNeedsDisplayInRect:]
#20 0x94db7d2c in -[NSScrollView setKeyboardFocusRingNeedsDisplayInRect:]
#21 0x94c2bb7e in -[NSScrollView setNeedsDisplayInRect:]
#22 0x94c9d48d in -[NSView setKeyboardFocusRingNeedsDisplayInRect:]
#23 0x94db7d2c in -[NSScrollView setKeyboardFocusRingNeedsDisplayInRect:]
#24 0x94c2bb7e in -[NSScrollView setNeedsDisplayInRect:]
#25 0x94c9d48d in -[NSView setKeyboardFocusRingNeedsDisplayInRect:]
#26 0x94db7d2c in -[NSScrollView setKeyboardFocusRingNeedsDisplayInRect:]
...With typical #macdev diplomacy, I've been told that bindings are the devil and that I should pursue an alternative approach. This is difficult to swallow because most examples of new cocoa code use bindings.I now plan to try using NSBrowser with a delegate as the data source.I've filed a bug report with apple. No response as of yet.Update:
It turns out that infinite recursion errors in Cocoa are a special class of error not necessarily caused by improper memory management. Often, the cause is the interaction of two gui compoments "bouncing" off of each other -- one calls a method in the other, which calls a method in the other ad infinitum. In my case the infinite recursion bug occurs only when all sides of an NSBrowser are flush with a containing NSWindow AND there are multiple columns of data currently being displayed.
Update Update:
I believe the problem now can be described more precisely as occurring only when the NSBrowser bottom right corner overlaps with the grab-triangle at the bottom right corner of the containing NSWindow. Not TOTALLY sure about that though.
[browser bind:@"content" toObject:treeController withKeyPath:@"arrangedObjects" options:nil]; [browser bind:@"contentValues" toObject:treeController withKeyPath:@"arrangedObjects.representedObject" options:nil];
NSLog(@"browser: %@", browser);Alas it is not meant to be. The NSBrowser object will inevitable cause a crash by infinitely recursing like so:...
#19 0x94c9d48d in -[NSView setKeyboardFocusRingNeedsDisplayInRect:]
#20 0x94db7d2c in -[NSScrollView setKeyboardFocusRingNeedsDisplayInRect:]
#21 0x94c2bb7e in -[NSScrollView setNeedsDisplayInRect:]
#22 0x94c9d48d in -[NSView setKeyboardFocusRingNeedsDisplayInRect:]
#23 0x94db7d2c in -[NSScrollView setKeyboardFocusRingNeedsDisplayInRect:]
#24 0x94c2bb7e in -[NSScrollView setNeedsDisplayInRect:]
#25 0x94c9d48d in -[NSView setKeyboardFocusRingNeedsDisplayInRect:]
#26 0x94db7d2c in -[NSScrollView setKeyboardFocusRingNeedsDisplayInRect:]
...With typical #macdev diplomacy, I've been told that bindings are the devil and that I should pursue an alternative approach. This is difficult to swallow because most examples of new cocoa code use bindings.I now plan to try using NSBrowser with a delegate as the data source.I've filed a bug report with apple. No response as of yet.Update:
It turns out that infinite recursion errors in Cocoa are a special class of error not necessarily caused by improper memory management. Often, the cause is the interaction of two gui compoments "bouncing" off of each other -- one calls a method in the other, which calls a method in the other ad infinitum. In my case the infinite recursion bug occurs only when all sides of an NSBrowser are flush with a containing NSWindow AND there are multiple columns of data currently being displayed.
Update Update:
I believe the problem now can be described more precisely as occurring only when the NSBrowser bottom right corner overlaps with the grab-triangle at the bottom right corner of the containing NSWindow. Not TOTALLY sure about that though.