A higher level object (PMController ) contains an NSMutableArray property which stores a collection of "PMProject" objects and an NSTreeController property to serve as the intermediary between the NSMutableArray and an NSOutlineView.

I'm setting up the NSTreeController like so:

- (void) initTableController
{
        tableController         = [[NSTreeController alloc] initWithContent: 
nil];
        [tableController setChildrenKeyPath: @"children"];
        [tableController setLeafKeyPath: @"isLeafNode"];
        // NOTE: PMController is a singleton class that stores an
        // NSMutable array of currently open PMProject objects
[tableController bind: @"contentArray" toObject: [PMController sharedController] withKeyPath: @"currentProjects" options: nil];
}

And am trying to bind the "name" column of the NSOutlineView to the NSTreeController like this

- (void) initMyProjectOutline
{
        // create text cell
        nameCell                = [[NSTextFieldCell alloc] init];
        
        // create the name column
        nameColumn              = [[NSTableColumn alloc] initWithIdentifier: 
@"name"];
        [nameColumn setDataCell: nameCell];
        [nameColumn setMinWidth: 1000];
        // bind value to MyProject:name accessor
// NOTE: I've tried both of the following but am getting nothing in the NSOutlineView "name" column [nameColumn bind: @"value" toObject: tableController withKeyPath: @"content.name " options: nil]; [nameColumn bind: @"value" toObject: [tableController content] withKeyPath: @"name" options: nil];
        
        // create the table
        table           = [[NSOutlineView alloc] initWithFrame: tableFrame];
        [table addTableColumn: nameColumn];
        [table setHeaderView: nil];
        [table setAutoresizingMask: NSViewWidthSizable | NSViewMaxYMargin];
        [table setUsesAlternatingRowBackgroundColors: YES];
        [table setFocusRingType: NSFocusRingTypeNone];
[table setColumnAutoresizingStyle: NSTableViewLastColumnOnlyAutoresizingStyle]; [table bind: @"content" toObject: tableController withKeyPath: @"content" options: nil];
        
        [self addSubview: table];


Reverse the order here. Add the column to the outlineView and then bind it (the column). The binding for the column should be [nameColumn bind: @"value" toObject: tableController withKeyPath: @"arrangedObjects.name " options: nil];

And you don't have to bind the outlineView's content at all. That happens automatically when you bind one of the outlineView's columns. By binding the column after it's added to the outlineView, you'll also get the sortDescriptors and selectionIndexPaths bindings set up for you.



--------------------------
RONZILLA

_______________________________________________

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

This email sent to [EMAIL PROTECTED]

Reply via email to