• 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
Getting *my* object out of a tree controller?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting *my* object out of a tree controller?


  • Subject: Getting *my* object out of a tree controller?
  • From: Randall Meadows <email@hidden>
  • Date: Thu, 5 Feb 2009 13:36:36 -0700

I have an NSOutlineView backed by an NSTreeController.

selectedObject = [[treeController selectedObjects] objectAtIndex:n]

gives me back an object (of the type) that I expect. However, when I then try to find where that object lives in the tree

[treeView rowForItem:selectedObject]

returns -1 (not found). I ultimately need to remove the object from the tree controller (using -removeObjectAtArrangedObjectIndexPath: presumably), but how do I get an index path to an object when I have *just* a pointer to that object? I can get an index path to the selection, but in this case, the object to be deleted may not actually be selected in the view. Based on the stuff I discovered below, I assume I need to be searching for the tree node representation of my object? How do I get that just from the object itself? Or do I need to remember that tree node information at the same time I get a handle to the object?

Thanks!
randy

-----
OK, I figured out the following part: NSTreeControllerTreeNode must be a NSTreeNode, on which I can call -representedObject, which returns me an object of the type I expect; I left the rest in here in case I'm mistaken somehow, someone can set me straight.


Even when I query the tree controller directly for its items, I don't get *my* object types back, but rather NSTreeControllerTreeNodes:

(gdb) po [treeView itemAtRow:1]
<NSTreeControllerTreeNode: 0x2a4a00>, child nodes {}
(gdb) po [treeView itemAtRow:0]
<NSTreeControllerTreeNode: 0x2d82b0>, child nodes { 0:<NSTreeControllerTreeNode: 0x2a4a00>, child nodes {}
1:<NSTreeControllerTreeNode: 0x2a4fb0>, child nodes {}
}


Not only can I not find any documentation on this type, I can't even cmd-double-click or search to find *any* mention of it at all. Casting that to my object type was an exercise in futility (what was displayed was obviously not a valid object).
_______________________________________________


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: Getting *my* object out of a tree controller?
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Confused about NSTrackingAreas with autoscroll [WORKAROUND]
  • Next by Date: Re: [Q] How can one programatically begin a text editing session in a NSTextField?
  • Previous by thread: Re: Encoding to use for file names
  • Next by thread: Re: Getting *my* object out of a tree controller?
  • Index(es):
    • Date
    • Thread