Re: Memory management with arrays
Re: Memory management with arrays
- Subject: Re: Memory management with arrays
- From: Andrew Merenbach <email@hidden>
- Date: Sat, 9 Feb 2008 22:12:33 -0800
Hi, Jacob,
Maybe I'm missing something, but this "should work." I suspect that
the problem lies elsewhere in your code. Can you give us (the list) a
little more information on your file, such as relevant surrounding code?
Also, apologies if this is a basic question, but is your array
definitely declared and instantiated properly? and, additionally, is
it an NSMutableArray, and not a standard NSArray?
Cheers,
Andrew
On Feb 9, 2008, at 7:48 PM, Jacob Bandes-Storch wrote:
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
_______________________________________________
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