• 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: Implementing NSOutlineView autosaveExpandedItems with CoreData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing NSOutlineView autosaveExpandedItems with CoreData


  • Subject: Re: Implementing NSOutlineView autosaveExpandedItems with CoreData
  • From: Andy Kim <email@hidden>
  • Date: Tue, 1 Jul 2008 00:05:17 -0700

Thanks - I've seen solutions like this before, I just wanted to get it working the regular way!

I totally understand the sentiment.

Is itemForPersistentObject expecting an NSTreeNode? You say you have it working in a similar way - what does your itemForPersistentObject method return?

Many thanks
Ian

Here's what I do:

- (id)outlineView:(NSOutlineView *)ov itemForPersistentObject:(id)object
{
return [[gAppDelegate library] groupWithUID:object]; // This fetches the group from the managed object context
}


- (id)outlineView:(NSOutlineView *)ov persistentObjectForItem:(id)item
{
	return [item uid];
}

According to the docs I'm supposed to archive the persistent object before returning it, but in my case, it doesn't matter because it's just a string and it all goes into a plist anyway. I have tried it both ways after seeing your implementation though, and there are indeed no differences.

I see why you're thinking that you need to return a NSTreeNode though. I don't need to do that because I don't use a NSTreeController and instead implement the data source protocol in my custom controller. So for me the item is the model object itself.

In your case, I'm fairly positive that you do need to return the NSTreeNode object. Instead of fetching the model object, walk the controller's content tree looking for the right representedObject with the UID.

- Andy Kim

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

  • Follow-Ups:
    • Re: Implementing NSOutlineView autosaveExpandedItems with CoreData
      • From: Ron Lue-Sang <email@hidden>
  • Next by Date: Re: Output of NSHTTPCookieStorage to NSTableView
  • Next by thread: Re: Implementing NSOutlineView autosaveExpandedItems with CoreData
  • Index(es):
    • Date
    • Thread