On 25 Feb 2008, at 22:31, Eckart Schlottmann wrote:

Hi,

I need some help on NSTreeController usage.

I use an NSTreecontroller with Garbage Collection and OBJ C 2.0.

I have a Structure of Nodes (class FileSystemEntry) which provide children as a NSMutableArray with a getter and setter for the complete arrays:


- (NSMutableArray *)internalChildren {
  return internalChildren;
}

- (void)setInternalChildren:(NSMutableArray *)newValue
{
        internalChildren = newValue;
}

-(BOOL) isLeaf {
        return isLeaf;
}

-(void)setLeaf:(BOOL)v {
        isLeaf=v;
}


Hi Eckart,

Firstly, if you're using GC, you can replace your internalChildren accessors with a property using the assign keyword:

@property(assign) NSMutableArray *internalChildren;

You're NSTreeController will also have a leaf key path (- setLeafKeyPath:) which you can set in IB if you want. You probably set it to isLeaf in which case you're method naming may need to be more consistent. Check the NSTreeController's childrenKeyPath is also set to internalChildren.

- (BOOL)isLeaf:
- (void)setIsLeaf:(BOOL)v;

Again, you're not doing anything special in the accessors you wrote so make it a property:

// MyNode.h
@property(assign) BOOL isLeaf;

//MyNode.m
@synthesize isLeaf;

You'll always need to use these accessors, not set the ivar directly.

Hope this helps, sorry if I've stated the obvious to you.

Jon
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to