On Apr 17, 2013, at 10:50 , Gordon Apple <g...@ed4u.com> wrote:

> We are converting tables and outlines to view-based.  So far, so good, on
> tables.  But NSOutlineView has been a pain.  First of all, there is no
> documentation on this, zero, zip, nada, zilch, in the NSOutlineView
> Reference.  You have to rely on sample code and NSOutlineView.h.

Yup, the documentation situation for NSOutlineView is awful.

> Our outline view has a column/cell identifier ³LineNumber², one for
> ³CheckBox², one for ³Outline².  Previously, the latter two were bound to our
> NSTreeController.  Converting to views (yes, using
> outlineView:viewForTableColumn:item:), we could not even get the nib to
> load.  ObjectValue always came up nil.  We tried binding the tableView to
> the tree controller ‹ still nil.  

You can't "try" binding here. If you're using a data source, you don't bind the 
outline view to the tree controller, and in that case you need to set 
view.objectValue to the desired object before returning from 
'outlineView:viewForTableColumn:item:'.

Otherwise, you *must* bind the outline view's "content" binding to the tree 
controller, and the outline view should then maintain "objectValue" for you. 
(But since I always use data sources these days, I can't swear that this is 
precisely correct.)

> Ok, after examining sample code, we
> decided that just maybe there was something magic about the column/cell
> identifier ³MainCell², so we changed our third column/cell identifier and
> replaced @²Outline² with @²MainCell² in our code.  Amazing ‹ now the nib
> loads.  However, still no values.

Since you're talking about loading nibs, I assume you've got code to register 
the nib, and I bet you forgot to ensure that the nib is registered with with 
the identifier that matches what you're actually using.

If I remember the details correctly, you're going to invoke 
'makeViewWithIdentifier:owner:' inside 'outlineView:viewForTableColumn:item:'. 
When you're using registered nibs, you must use the identifier that the nib is 
registered under, and the identifier assigned to the built-in cell view (that 
you're not using) is irrelevant. When you're using the built-in cell view, you 
must use its identifier, of course.

The column identifier is basically unrelated, unless you *choose* to configure 
it to match the actual cell view identifier. The table view documentation 
assumes this is desirable, but I've never found it makes anything much easier. 
All it does is provide the opportunity for things to get out of sync, as you 
discovered.

>  Even worse, the turn-down dingy appears
> in the first column, not the third where we want it.  It does turn down the
> right number of times and depths to match our outline, but is in the wrong
> place and no values.
> 
> So how do I get the outline back into the third column and get my
> objectValues to work?

Are you sure you aren't inadvertently returning a group row view, or a full-row 
view?

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to