From: Stephyn B. <ste...@co...> - 2008-08-03 02:30:18
|
Dear all, Thank you for your forbearance...as I'm not sure this is exactly a RubyCocoa question. I've written an application that quite successfully uses a bunch of NSArrayControllers to manipulate a bunch of models using Bindings. However, one part of the application requires a user to manipulate something that is best represented as a tree. Therefore, I'm using the NSOutlineView. I'm not using the NSTreeController based many comments and posts I've seen on the Internet which say to avoid it especially if the user is manipulating the tree. Based on an example I found online, "OutlineMeRuby", I successfully implemented a NSOutlineView and DataSource that do what I want them to do. The problem is that now, I'm trying to integrate this editor into the other, binding-based editors of my application. So that when someone selects a Model in one tab, they can start editing one of the properties of that Model, which is a tree. The actual building of the tree is complicated because the nodes that are actually displayed are a facade for the real tree. So basically, I have my DataSource do this: class FaultTreeDataSource < NSObject ib_outlets :outlineView, :tests, :testsAlias, :modelsAlias def awakeFromNib self.bind_toObject_withKeyPath_options_( "root", @modelsAlias, "selection.entry", nil) end @root = nil def root=( object) @root = object NSLog( "the root was set to #{@root}") @outlineView.reloadItem @root end def root NSLog( "root getter is returning #{@root}") @root end # more methods for DataSource, addChild, etc. end Based on the NSLog output, the root object is most definitely being set through the bindings and it is a FaultTreeDisplayNode. For the longest time, I couldn't get the NSOutlineView to acknowledge the @root object at all. Even though this same code worked previously without bindings. Now I'm getting the following error when I click the tab that displays the NSOutlineView: 2008-08-02 22:13:48.481 FaultTreeDiagnosis[1682:10b] root is <FaultTreeDisplayNode: 0x5c8000> 2008-08-02 22:13:48.482 FaultTreeDiagnosis[1682:10b] root getter is returning <FaultTreeDisplayNode: 0x5c8000> 2008-08-02 22:13:48.482 FaultTreeDiagnosis[1682:10b] *** - [FaultTreeDisplayNode copyWithZone:]: unrecognized selector sent to instance 0x5c8000 /Users/stephyn/Desktop/rubycocoa/projects/FaultTreeDiagnosis/build/ Debug/FaultTreeDiagnosis.app/Contents/Resources/rb_main.rb:22:in `NSApplicationMain': NSInvalidArgumentException - *** - [FaultTreeDisplayNode copyWithZone:]: unrecognized selector sent to instance 0x5c8000 (OSX::OCException) from /Users/stephyn/Desktop/rubycocoa/projects/FaultTreeDiagnosis/ build/Debug/FaultTreeDiagnosis.app/Contents/Resources/rb_main.rb:22 I have no idea why the FaultTreeDisplayNode is being sent the copyWithZone selector nor have I ever seen anything that requires you to do so for either Bindings or DataSources. Any ideas? Cheers, Steve |