You need to retain your array since arrayWithCapacity returns an autoreleased object.

And in dealloc, release the array, and set to nil if you want to but not necessary.

Devon

Allan Greenier wrote:
This is so simple I know the answer will embarrass me.
This is an iPhone app.
I've got an NSMutable array declared in my EAGLview.h file

NSMutableArray *boxes;

I init and fill it in the EAGLview's initWithCoder method

        boxes = [NSMutableArray arrayWithCapacity:NUM_BOXES];
for(i = 0; i < NUM_BOXES; i++) { Box *abox = [[Box alloc] init];
        [boxes addObject: abox];
}
In EAGLview dealloc I

    boxes = nil;

Later on in program flow, in EAGLview, if I try to access boxes in anyway, I crash into the debugger

[boxes objectAtIndex: 0];

or even

NSLog(@"mode5 boxes  %@",  boxes);

will crash

What am I missing? What's wrong with my NSMutableArray?
My only guess is it's in my for loop, I need to release abox?


Thanks,
Allan



_______________________________________________

Cocoa-dev mailing list ([email protected])

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/dferns%40devonferns.com

This email sent to [email protected]
_______________________________________________

Cocoa-dev mailing list ([email protected])

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