Allocation and disposal inside a loop
Allocation and disposal inside a loop
- Subject: Allocation and disposal inside a loop
- From: Ken Tozier <email@hidden>
- Date: Tue, 4 Feb 2003 00:08:43 -0500
I've managed to confuse myself about what will happen in the following
code. Could anyone tell me whether the "release" method call at the
bottom of the loop trashes items that have already been placed in the
array?
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];
}
Thanks,
Ken
_______________________________________________
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.