Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Implementing NSOutlineView autosaveExpandedItems with CoreData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing NSOutlineView autosaveExpandedItems with CoreData




On Jul 1, 2008, at 12:05 AM, Andy Kim wrote:

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


Andy, you're right.
Ian's code needs to return an NSTreeNode. Please file a bug that this is too hard.




_______________________________________________

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


--------------------------
RONZILLA



_______________________________________________

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


References: 
 >Re: Implementing NSOutlineView autosaveExpandedItems with CoreData (From: Andy Kim <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.