Memory management with arrays
Memory management with arrays
- Subject: Memory management with arrays
- From: Jacob Bandes-Storch <email@hidden>
- Date: Sat, 9 Feb 2008 19:48:48 -0800
I have an array that is an instance variable. I'm trying to add an
object to it, and autorelease that object, so the next time this
happens, I can remove all objects in the array and the object will be
gone.
- (void)foo {
[array removeAllObjects];
Bar *bar = [[Bar alloc] init];
[array addObject:[bar autorelease];
}
This should remove all the objects, and add a new one. Basically, I
want the old Bar instance gone, and the new one in the array. However,
when I do this, I get an EXC_BAD_ACCESS when it tries to -
removeAllObjects. What's the problem?
_______________________________________________
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