• 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
NSOutlineView problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSOutlineView problem


  • Subject: NSOutlineView problem
  • From: jordibares <email@hidden>
  • Date: Wed, 11 Apr 2007 19:17:43 -0300
  • Thread-topic: NSOutlineView problem

I am running into a funny behavior with NSOutlineView when adding objects
because does not display in the outline view the child nodes when I do
create these child nodes from a method. When these nodes are created from
the init method then it works.

My code is based on OutlineMe code from Aaron Hillegass example and I have
checked all I can think of...



Basically this works;

----------------------------------------------------------------------------
------------------
> - init
> {
>     [super init];
>     rootNode = [[OutlineNode alloc] init];
>     [rootNode setItemName: @"Root"];
>
>     // Local variables
>     OutlineNode *newNode;
>
>     // Create a new child node
>     newNode = [[OutlineNode alloc] init];
>     [newNode setItemName:[theComputerNode name]];
>
>     // Add the computer node name to the root
>     [rootNode addChild:newNode];
>
>     // Parent node is retaining the new node
>     [newNode release];
>
>     // Brute force refresh
>     [outlineView reloadItem:rootNode reloadChildren:YES];
>
>     return self;
> }
>
>
> - (void)addComputerNode:(Computer *)theComputerNode
> {
> }
----------------------------------------------------------------------------
------------------



But this does not!

----------------------------------------------------------------------------
------------------
> - init
> {
>     [super init];
>     rootNode = [[OutlineNode alloc] init];
>     [rootNode setItemName: @"Root"];
>
>     return self;
> }
>
>
> - (void)addComputerNode:(Computer *)theComputerNode
> {
>     // Local variables
>     OutlineNode *newNode;
>
>     // Create a new child node
>     newNode = [[OutlineNode alloc] init];
>     [newNode setItemName:[theComputerNode name]];
>
>     // Add the computer node name to the root
>     [rootNode addChild:newNode];
>
>     // Parent node is retaining the new node
>     [newNode release];
>
>     // Brute force refresh
>     [outlineView reloadItem:rootNode reloadChildren:YES];
> }
----------------------------------------------------------------------------
------------------

When I log the number of child under root it returns 1 after the addition in
both examples, also I can access these values programatically but in the
outline view these don¹t appear.

Here is the code from the Data Source methods
----------------------------------------------------------------------------
------------------
        //
----------------------------------------------------------------------------
------------
> // DATA SOURCE METHODS
> //
> ------------------------------------------------------------------------------
> ----------
> #pragma mark -
> #pragma mark datasource methods
>
> // This method is called repeatedly when the table view is displaying it self.
> - (id)outlineView:(NSOutlineView *)ov
>             child:(int)index
>            ofItem:(id)item
> {
>     // is the parent non-nil? Return the child, Else return the root
>     if ( item != nil )
>     {
>         return [item childAtIndex:index];
>     }
>     else
>     {
>         return rootNode;
>     }
> }
>
> // Called repeatedly to find out if there should be an "expand triangle" next
> to the label
> - (BOOL)outlineView:(NSOutlineView *)ov
>    isItemExpandable:(id)item
> {
>     // Returns YES if the node has children
>     return [item isExpandable];
> }
>
> // Called repeatedly when the table view is displaying itself
> - (int)outlineView:(NSOutlineView *)ov
> numberOfChildrenOfItem:(id)item
> {
>     return (item == nil) ? 1 : [item childrenCount];
> }
>
> // This method gets called repeatedly when the outline view is trying
> // to display it self.
>
> - (id)outlineView:(NSOutlineView *)ov
>     objectValueForTableColumn:(NSTableColumn *)tableColumn
>            byItem:(id)item
> {
>     return [item itemName];
> }
----------------------------------------------------------------------------
------------------



Any pointer would be appreciated, thanks in advance.

Jordi Bares


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: NSOutlineView problem
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: WM_KEYDOWN
  • Next by Date: re: CoreData Updating Max pk error?
  • Previous by thread: Re: Problem with AESend()
  • Next by thread: Re: NSOutlineView problem
  • Index(es):
    • Date
    • Thread