Re: Programmatically get treecontroller selection
Re: Programmatically get treecontroller selection
- Subject: Re: Programmatically get treecontroller selection
- From: Steven Hamilton <email@hidden>
- Date: Wed, 21 May 2008 19:53:35 +1000
On 21/05/2008, at 4:01 AM, Jonathan Dann wrote:
In addition:
So, I guess my question is: how is your NSOutlineView populated? Do
you have to NSTableColumn of the NSOutlineView bound to the tree
controllers @"arrangedObjects.name" keypath? If this is the case, in
what way are you giving the tree controller content to work with.
Sorry folks, I forgot to mention the status of the other components.
The NSOutlineView and NSTreeController and related bindings work fine.
The treecontroller is indeed in entity mode and uses the Account
entity with a recursive relationship called "accounts" as he children
path. The treecontrollers only binding is for the managedObjectContext.
The NSOutlineView Content has Content set to the treecntrollers
arrangedObjects and the SelectionIndexPath set to the treecontrollers
selectionIndexPath (as expected).
As a test I have the window title bound to the
treecontroller.selection.name path (name is a property of Account
remember). Changing selection changes the window title no problemo.
Some further hacking over the last couple of days has got me no
further forward. However, I have tidied up my code a bit so I'll
requote it below.
#import "MLtableController.h"
#import "moolahcoredata_AppDelegate.h"
@implementation MLtableController
- (void)awakeFromNib{
//register as observer of tableview
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(getSelectedAccount)
name:@"NSOutlineViewSelectionDidChangeNotification"
object:MLoutlineView];
}
- (void)getSelectedAccount{
NSString *accountName = @"Bank";
NSLog(accountName);
accountName = [[MLoutlineViewController selection]
valueForKey:@"name"];
NSLog(accountName);
//get managedObjectContext in preparation for fetch code
moc = [MLappDelegate managedObjectContext];
}
_______________________________________________
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