NSTableCellView for view-based outline view
NSTableCellView for view-based outline view
- Subject: NSTableCellView for view-based outline view
- From: Quincey Morris <email@hidden>
- Date: Tue, 19 Nov 2013 20:42:37 -0800
Here’s something puzzling, unless I’m missing the obvious:
I’m intending to convert an outline view in an existing xib file from cell-based to view-based. In preparation, I added the requisite delegate method to the view controller:
> - (NSView*) outlineView: (NSOutlineView*) outlineView viewForTableColumn: (NSTableColumn*) column item: (id) item {
> if (!item || !column)
> return nil;
> NSTableCellView* view = [outlineView makeViewWithIdentifier: column.identifier owner: self];
> if (!view)
> return nil;
> return view;
> }
without changing the outline view itself. Somewhat to my surprise, this delegate method *was* called for the outline view, and had the effect of causing all of the cells to display no value. I repeat: the outline view was still cell-based at this stage.
(The reason I tried this is that I first attempted to add a view-based outline view above the original, so I could compare the results. I needed the delegate method for the new view, but it was called for both views. So I started over, as described above.)
So that’s weird problem #1: surely this delegate method shouldn’t be called for a cell-based outline view? Incidentally, the backtrace at the delegate method looks like this:
> frame #1: 0x00007fff94d84934 AppKit`-[NSTableView(NSTableViewViewBased) makeViewForTableColumn:row:] + 77
> frame #2: 0x00007fff94d83c67 AppKit`-[NSTableRowData _addViewToRowView:atColumn:row:] + 305
> frame #3: 0x00007fff94d8399a AppKit`-[NSTableRowData _addViewsToRowView:atRow:] + 191
> frame #4: 0x00007fff94d80a8e AppKit`-[NSTableRowData _addRowViewForVisibleRow:withPriorView:] + 421
> frame #5: 0x00007fff94d8080c AppKit`-[NSTableRowData _addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] + 278
> frame #6: 0x00007fff94d7f8d6 AppKit`-[NSTableRowData _unsafeUpdateVisibleRowEntries] + 1640
> frame #7: 0x00007fff94d7f16c AppKit`-[NSTableRowData updateVisibleRowViews] + 230
> frame #8: 0x00007fff94d7ed94 AppKit`-[NSTableView layout] + 165
which looks odd. But even if a cell-based outline view is (now in Mavericks) using a view-based table view under the hood, it shouldn’t be calling this delegate method, should it?
OK, ignoring that and moving on, I deleted the old outline view, added a new one, and set it to “view-based”. Now, I find that the result of creating the cell view in the delegate method:
> NSTableCellView* view = [outlineView makeViewWithIdentifier: column.identifier owner: self];
isn’t a NSTableCellView at all:
> (lldb) po view
> <NSView: 0x600000323b60>
> (lldb) po [view class]
> NSView
> (lldb) po [view objectValue]
> error: Execution was interrupted, reason: Attempted to dereference an invalid ObjC Object or send it an unrecognized selector.
> The process has been returned to the state before expression evaluation.
That’s weird problem #2. The table cell view item in IB has the default class (“NSTableCellView” in gray) in the inspector, but the outline view is not creating a cell view of that class. Huh? The consequence is that I can’t get a value into the text field of the cell view.
Anyone know what’s going on here?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden