Re: Programmatically get treecontroller selection
Re: Programmatically get treecontroller selection
- Subject: Re: Programmatically get treecontroller selection
- From: Steven Hamilton <email@hidden>
- Date: Thu, 22 May 2008 07:00:35 +1000
Fixed that error now. I had a rogue arraycontroller in the NIB file
from a previous predicate exercise. The nib is cleaned up and still no
selection. It appears that I'm unable to get anything other than NULL
from any objects instantiated in the NIB file. My appDelegate holds
the code for the manageObjectContext and my method in my datasource to
get that also just returns null. At the moment I'm puting this down to
me not quite understanding Obj-C enough to communicate with out custom
objects. Going to go read a book.
For completeness, here is my interface file. Do I have to declare NIB
objects in order to use them like I've done below? I think this is
where I'm falling down.
#import <Cocoa/Cocoa.h>
#import "moolahcoredata_AppDelegate.h"
@interface MLtableController : NSObject {
NSOutlineView *MLoutlineView;
NSTreeController *MLoutlineViewController;
moolahcoredata_AppDelegate *MLappDelegate;
}
- (void) getSelectedAccount;
@end
On 22/05/2008, at 5:45 AM, Hamish Allan wrote:
I'd like to reiterate what Quincey noted:
"BTW, I notice that the "Cannot perform operation without a managed
object context" error is logged *before* you log "default". The
problem is not apparently anything to do with getting the selection in
the code you posted, since it happens before you do that."
You should try to find out what causes the "Cannot perform..." message
first and foremost -- perhaps by setting a breakpoint on NSLog()?
Hamish
On Wed, May 21, 2008 at 7:32 PM, Jonathan Dann <email@hidden>
wrote:
- (void)getSelectedAccount{
NSString *accountName = @"Bank";
NSLog(accountName);
accountName = [[MLoutlineViewController selection]
valueForKey:@"name"];
NSLog(accountName);
//get managedObjectContext in preparation for fetch code
moc = [MLappDelegate managedObjectContext];
}
At first glance, try NSTreeController's -selectedObjects and -
selectedNodes
methods rather than -selection. Also, in my experience I've not
found is
necessary to bind the selectionIndexPath(s) to the outline view to
get it
all to work, maybe unbind that as a quick test?
Jon
_______________________________________________
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
_______________________________________________
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