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 19:11:17 +1000
All sorted.
Turns out that in my obsession with bindings and coredata I forgot
that to communicate with objects in a NIB you need to use Outlets.
Doh! I've now setup outlets from my datasource to the controllers and
can pull the selection and context out no problems.
Thanks for bearing with me, and apologies for being such a n00b.
(also, selectionIndexPaths binding is required in the NSOutlineView,
no idea why either)
On Wed, May 21, 2008 at 10:00 PM, Steven Hamilton <email@hidden>
wrote:
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
_______________________________________________
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