From: Allison N. <dem...@ma...> - 2008-05-28 13:19:19
|
Hi everyone, I'm having some trouble with implementing an NSOutlineView data source. Currently, I have created a class called OutlineViewItem, which is defined as follows: class OutlineViewItem < NSObject attr_accessor :name, :ary def numberOfChildren @ary.size end def isItemExpandable @ary != nil end def getChild(index) @ary[index] end def to_s "OutlineViewItem:#{@name} #{@ary.size}" end end where @name is a ruby String, and @ary is a ruby Array. I have three of these objects that are added to the root of the NSOutlineView, and they are correctly displayed in the outline view, with the triangle next to them indicating that each is expandable (as each is initialised with several items in it's @ary). However, when I try to call getChild in the outlineView_child_ofItem method of the NSOutlineView DataSource (where the item given by the NSOutlineView is an object of class OutlineViewItem), my app dies when the OutlineViewItem tries to recover one of it's children from it's @ary. Specifically, the backtrace looks like this: #0 0x000356e9 in rbobj_get_ocid () #1 0x0002d0db in rbobj_to_nsobj () #2 0x0002d776 in rbobj_to_ocdata () #3 0x0002ef43 in sel_to_rbobj () #4 0x0004130c in ffi_prep_cif_machdep () #5 0x9164b4e6 in -[NSOutlineView _dataSourceChild:ofItem:] () #6 0x9164b3a5 in loadItemEntryLazyInfoIfNecessary () #7 0x9164cb5a in -[NSOutlineView _rowEntryForChild:ofParent:requiredRowEntryLoadMask:] () #8 0x9164bf5a in -[NSOutlineView _expandItemEntryChildren:atStartLevel:expandChildren:andInvalidate:] () #9 0x917a1b4f in -[NSOutlineView _expandItemEntry:expandChildren:startLevel:] () #10 0x917a15aa in -[NSOutlineView _expandItemEntry:expandChildren:] () #11 0x9164b96e in -[NSOutlineView _batchExpandItemsWithItemEntries:expandChildren:] () #12 0x9164b6d1 in -[NSOutlineView expandItem:expandChildren:] () #13 0x9182af1a in -[NSOutlineView _doUserExpandOrCollapseOfItem:isExpand:optionKeyWasDown:] () #14 0x9182aa1e in -[NSOutlineView mouseTracker:didStopTrackingWithEvent:] () #15 0x9182a84e in -[NSMouseTracker stopTrackingWithEvent:] () #16 0x9179ceb7 in -[NSMouseTracker trackWithEvent:inView:withDelegate:] () #17 0x916e1dde in -[NSOutlineView mouseDown:] () #18 0x91688ac3 in -[NSWindow sendEvent:] () #19 0x91655714 in -[NSApplication sendEvent:] () #20 0x915b30f9 in -[NSApplication run] () #21 0x9158030a in NSApplicationMain () #22 0x0004163d in ffi_call_SYSV () #23 0x000415e2 in ffi_call () #24 0x0003e9b3 in rb_ffi_dispatch () #25 0x000374a9 in find_bs_boxed_by_encoding () #26 0x000d1057 in rb_with_disable_interrupt () #27 0x000da18c in rb_eval_string_wrap () #28 0x000dad6a in rb_eval_string_wrap () #29 0x000d80da in rb_eval_string_wrap () #30 0x000e706e in rb_load_protect () #31 0x000e709f in ruby_exec () #32 0x000e70cb in ruby_run () #33 0x00034ae3 in RBApplicationMain () #34 0x00001fed in main (argc=1, argv=0xbffff750) at /Users/demallien/Code/Exerciser/main.m:14 I get the impression that my OutlineViewItem instance is getting corrupted as it moves back and forth across the bridge. Does anyone have any hints for correctly implementing an NSOutlineView datasource, or better, can explain why my app is dying? Thanks for any help. Alli |