• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Programmatically get treecontroller selection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Programmatically get treecontroller selection


  • Subject: Programmatically get treecontroller selection
  • From: Steven Hamilton <email@hidden>
  • Date: Mon, 19 May 2008 22:29:02 +1000

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.
_______________________________________________


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


  • Follow-Ups:
    • Re: Programmatically get treecontroller selection
      • From: Jonathan Dann <email@hidden>
  • Prev by Date: How to handle bad certificate error in NSURLDownload?
  • Next by Date: A documetation suggestion (was Re: Cocoa et al as HCI usability problem)
  • Previous by thread: Re: How to handle bad certificate error in NSURLDownload?
  • Next by thread: Re: Programmatically get treecontroller selection
  • Index(es):
    • Date
    • Thread