Re: Programmatically get treecontroller selection
Re: Programmatically get treecontroller selection
- Subject: Re: Programmatically get treecontroller selection
- From: Jonathan Dann <email@hidden>
- Date: Mon, 19 May 2008 20:18:09 +0100
On 19 May 2008, at 13:29, Steven Hamilton wrote:
I have a core data master-detail interface that consists of a
sourcelist on the left and a tableview.
The source list displays object from a core data entity. THe table
view will be populated by a custom datasource as I have to do some
data munging on the way from core data to the tableview. My custom
controller (datasource) is based on NSObject and has the standard
tableview delegate methods.
The tableview is also populated based on the selected item in the
source list. So I've setup a notification from the outlineview to
call a method in my custom controller. This works fine and when I
execute it I'm trying to get the outlineview's treecontrollers
selection like so;
NSString *accountName = @"default"; //set initial string value
NSLog(accountName); // check logging
object = [MLoutlineViewController selection]; //get selection object
from treecontroller (proxy of core data entity)
accountName = [object valueForKey:@"name"]; //get name property
from object
The object being returned from the selection is always NULL.
Console shows the following;
2008-05-19 22:25:46.990 moolahcoredata[664:10b] Cannot perform
operation without a managed object context
2008-05-19 22:25:46.996 moolahcoredata[664:10b] default
Now, I know the context error is probably because the outlineview
starts up with an item selected, probably before core data is
initialised properly. I've also read that every controller has to
have the context bound. My controller is based on NSObject, it
doesn't have bindings and I'd rather do things programmatically just
now. Do I need to somehow use the context to get the selection? If
so, how? I know context is needed for adding, fetching etc but to
get an object from a treecontroller? I don't think so somehow.
A few things here make me think that you haven't got the idea of using
NSControllers at all. If you've coded up an NSOutlineView datasource
then the tree controller has nothing to do with your setup. Without
bindings how have you linked the tree controller to the outline view?
The way its traditionally (and designed to be) used is that the tree
controller is the outline view's data source. The tree controller is
then bound to the managed object context.
There are many tutorials online about how to set this up with and
without Core Data. Can you clarify your setup please.
Jon
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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