• 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
Re: NSTreeController, Core Data and root objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTreeController, Core Data and root objects


  • Subject: Re: NSTreeController, Core Data and root objects
  • From: Steve Steinitz <email@hidden>
  • Date: Fri, 6 Nov 2009 08:35:20 +1100

Hi Rob,

On 5/11/09, Rob Keniger wrote:

as I add a new item to the top level it fails because the tree controller does not assign the "invisible" root item as the parent of the new item.

Fritz's idea looks much cooler (I might try it) but for a clumsier solution, have you written your own method to add new top-level items? I wonder if an IBAction like this would work:


- (IBAction)
addVisibleTopLevelItem: sender
{
YourEntity *invisibleTop = [self topObject];
YourEntity *newVisibleTop =
[NSEntityDescription insertNewObjectForEntityForName: @"YourEntity"
inManagedObjectContext: [context]];
[newVisibleTop setParent: invisibleTop]; // does your entity have a setParent?
// might also need to add a child to inVisibleTop
[treeController addObject: newVisibleTop];
[treeController rearrangeObjects]; // needed?
}


Something along similar lines seems to work for me.

Cheers,

Steve

_______________________________________________

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: NSTreeController, Core Data and root objects
      • From: Rob Keniger <email@hidden>
  • Prev by Date: Re: How to retrieve document type?
  • Next by Date: Re: Core Data, multiply values when inserted and show immedialty
  • Previous by thread: Re: NSTreeController, Core Data and root objects
  • Next by thread: Re: NSTreeController, Core Data and root objects
  • Index(es):
    • Date
    • Thread