• 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: NSOutlineView, NSTreeController and itemForPersistentObject...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOutlineView, NSTreeController and itemForPersistentObject...


  • Subject: Re: NSOutlineView, NSTreeController and itemForPersistentObject...
  • From: Thomas Lachand-Robert <email@hidden>
  • Date: Sun, 8 May 2005 21:54:28 +0200


Le 8 mai 05 à 15:22, Keith Blount a écrit :

If anyone here has played with NSTreeController and outine views and managed to get the outline view to save its state (and use other datasource/delegate methods that use (id)item), I would be really grateful if you could point me in the right direction, as I'm sure I must be missing something here. At the moment, it looks like I'm going to have to abandon NSTreeController...

--- Keith Blount <email@hidden> wrote:

Hello,

For instance, if you hook up a datasource to an
NSOutlineView that uses bindings (eg. the one in the
OutlineEdit Core Data example) and then try to use a
datasource method such as
outlineView:persistentObjectForItem:, you will find
that the "item" object passed in is not the actual
object, but a proxy object of class
_NSArrayControllerTreeNode.

When I was experiencing a similar problem a few days
ago, Scott Stevenson on this list very helpfully
pointed out that the only way he knew around this
was
to use an undocumented method, -observedObject.
Calling this on the item passed into outline view
datasource and delegate methods does indeed retrieve
the object.

However, I am now trying to get my outline view to
save its state using the datasource methods, and
whilst I can use -observedObject to get a persistent
object in outlineView:persistentObjectForItem:,
there
is no way to use this information to restore things
in
outlineView:itemForPersistentObject:, because
NSTreeController will expect this to return an
object
of type _NSArrayControllerTreeNode - a private API
class.


Dear Keith,

I'm myself trying to use the combination NSOutlineView +NSTreeController, but I'm not so advanced than you are, so my comments may be of no help: I apologize in advance. (I have asked myself a few questions recently on the list on this subject, but didn't get any answer :-(.)

I tried using -observedObject and indeed it does work well. You can silent the compiler warnings by putting these lines in your code:

@interface NSObject (privateAppkit)

-(id) observedObject;

@end

I have still to understand the complete connection between the controller, when an NSTreeController is used, and the ouline view. Anyway I use the tree controller also as a delegate, and it seems to work perfectly. (I use a derived class implementing some of the delegate methods). Apparently no data source is needed when using Core Data.

For the -outlineView:itemForPersistentObject: problem, I have no good solution. However, these methods only purpose is to save the expanded/ collapsed state of the items, right? So did you try to save this state into the model, and use the delegate methods - outlineViewItemDidCollapse: and similar to keep this state consistent with the view?

Yours,

Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet à la chose. >> Molière, Tartuffe.


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: NSOutlineView, NSTreeController and itemForPersistentObject... (From: Keith Blount <email@hidden>)

  • Prev by Date: drawPageBorderWithSize: and NSPrintScalingFactor breakage in Tiger
  • Next by Date: Spotlight: Indexing WebKit archives
  • Previous by thread: Re: NSOutlineView, NSTreeController and itemForPersistentObject...
  • Next by thread: Tiger, Interface Builder and NSScrollViews?
  • Index(es):
    • Date
    • Thread