Hi,

i am implementing a datasource for an nsoutlineview to represent the
contents of a simple tree-structure defined by the following class
(simplified):

@interface TBCatalogNode : NSObject {
    NSMutableArray* children;
}
@property (readonly, retain) NSMutableArray* children;

(the array children is created by the constructor is definately never nil)

my data source looks like this:

-(CatalogRepresentation*) initWithNode:(TBCatalogNode*)rootNode {
    if (self = [super init]) {
        root = [rootNode retain];
    }
    return self;
}

- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index
ofItem:(id)item {
    TBCatalogNode* objItem = (item == nil) ? root : item;
    return [[[objItem children] objectAtIndex:index] retain];
}

- (NSInteger)outlineView:(NSOutlineView *)outlineView
numberOfChildrenOfItem:(id)item {
    return (item == nil) ? [[root children] count] : [[item children]
count];
}

- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
    return ([self outlineView:outlineView numberOfChildrenOfItem:item] > 0);
}

- (id)outlineView:(NSOutlineView *)outlineView
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
    TBCatalogNode* objItem = (item == nil) ? root : item;
    return [[[objItem preset] info] objectForKey:@"ID"];  // this line gets
a string from a nsdictionary
}

This code works perfect with the garbage collection activated. when i
disable the gc it is working just at the begining, it shows the first level
under the root. when i click to expand an item it crashes -> debugger is
telling me at numberOfChildrenOfItem: - function.
I dont know what in the background is going on as I am pretty new to OSX. I
guess it is about some memory management, threading ?! I tried to retain
nearly everything, and I am running out of ideas.

The best solution would be to use the garbage collection of course, but I
need to load some bundles which are not compiled for gc. Is there a way to
load these bundles anyway? I tried to disable gc for the pointer of the
bundle, but that failed.

Thanks in advance
_______________________________________________

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