FROM : Jonathan Dann
DATE : Mon May 19 21:18:09 2008
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
DATE : Mon May 19 21:18:09 2008
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
| Related mails | Author | Date |
|---|---|---|
| Steven Hamilton | May 19, 14:29 | |
| Jonathan Dann | May 19, 21:18 | |
| Hamish Allan | May 19, 22:12 | |
| Steven Hamilton | May 20, 12:10 | |
| Quincey Morris | May 20, 19:18 | |
| Jonathan Dann | May 20, 19:55 | |
| Jonathan Dann | May 20, 20:01 | |
| Steven Hamilton | May 21, 11:53 | |
| Jonathan Dann | May 21, 20:32 | |
| Hamish Allan | May 21, 21:45 | |
| Steven Hamilton | May 21, 23:00 | |
| Steven Hamilton | May 22, 11:11 |






Cocoa mail archive

