Re: Allocation and disposal inside a loop
Re: Allocation and disposal inside a loop
- Subject: Re: Allocation and disposal inside a loop
- From: Nathan Day <email@hidden>
- Date: Tue, 4 Feb 2003 17:34:58 +1030
you will get a memory leak if both init methods fail. The release only
lets go of your hold of an object, but the addObject method will retain
them it's self so thats not a problem.
On Tuesday, February 4, 2003, at 03:38 PM, Ken Tozier wrote:
NSMutableArray *theArray = [[NSMutableArray alloc] init];
MyClass *tempObj;
while (startPtr < endPtr)
{
tempObj = [MyClass alloc];
if ([tempObj initializer1:&startPtr end:endPtr] != nil)
[theArray addObject:tempObject];
else if ([tempObj initializer2:&startPtr end:endPtr] != nil)
[theArray addObject:tempObject];
else break;
startPtr += [tempObj length];
[tempObject release];
}
Nathan Day
http://homepage.mac.com/nathan_day/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.