Fwd: NSTreeController, NSBrowser image setting
Fwd: NSTreeController, NSBrowser image setting
- Subject: Fwd: NSTreeController, NSBrowser image setting
- From: Tony Romano <email@hidden>
- Date: Wed, 24 Mar 2010 01:58:38 -0700
> From: Tony Romano <email@hidden>
> Date: March 24, 2010 1:57:04 AM PDT
> To: Cocoa Developers <email@hidden>
> Subject: Re: NSTreeController, NSBrowser image setting
>
> Thanks Ken, that was somewhat helpful. However, I am still having trouble mapping the arguments passed via(- (void)browser:(NSBrowser *)browser willDisplayCell:(id)cell atRow:(NSInteger)row column:(NSInteger)column; ) and which object it is referring to. With this little snippet I can get to all the children under the root.
>
>
> // treeView is the outlet to the NSTreeController object.
> NSArray *a = [[treeView arrangedObjects] childNodes];
>
> for (NSTreeNode *tn in a)
> {
> // node is the object that I provided to the treeController to represent each entry in the tree
> node *n = [tn representedObject];
> }
>
> The other method supported by the proxy, (NSTreeNode *)descendantNodeAtIndexPath:(NSIndexPath *)indexPath, requires an NSIndexPath object to access any child node in the tree. Building the NSIndexPath seems to be the big blocker. None of the methods for aNSBrowser will let you create an NSIndexPath if the data provided to the browser was not done via a data source. I am assuming I am missing something here.
>
> This is how I am assuming it would work
>
> NSTreeNode *nodeThatWillBeDisplayed = [treeView NSTreeNode *)descendantNodeAtIndexPath:someIndexPath];
> node *n = [nodeThatWillBeDisplayed representedObject];
> // Get the icon for the node
> // Set the image in the cell passed in via willDisplayCell
> // Life is good, move on.
>
>
> Anyone that can add some clarity to this, I would be greatly appreciate.
>
> -Tony
>
>
> On Mar 23, 2010, at 7:33 PM, Ken Thomases wrote:
>
>> On Mar 23, 2010, at 9:22 PM, Tony Romano wrote:
>>
>>> I'm using a NSTreeController and bindings to contain the data for a NSBrowser. Data from my objects is being displayed fine. I want to add an image to the entries in the browser. From what I gather, I need to implement the willDisplayCell delegate method. The question I have is how do I get MY object stored for the node being displayed. The documents state you cannot use the itemAt* methods if you did not use a data source, which I didn't. I did find on the Internet someone else who had a similar problem and the solution they found was call this method [item representedObject]. It's not clear what the receiver 'item' is.
>>
>> NSTreeController uses its own objects as the items. In Leopard and later, they are NSTreeNode instances. Prior to that, they were completely opaque objects.
>>
>> See <http://developer.apple.com/mac/library/releasenotes/Cocoa/AppKitOlderNotes.html#NSTreeController>.
>>
>> Regards,
>> Ken
>>
>>
>
> -tony
>
>
-tony
_______________________________________________
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