• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Allocation and disposal inside a loop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Allocation and disposal inside a loop
      • From: email@hidden (Simon Fraser)
    • Re: Allocation and disposal inside a loop
      • From: Nathan Day <email@hidden>
  • Prev by Date: Re: IB palettes and [NSBezierPath setDefaultLineWidth:]
  • Next by Date: Sorting an NSOutlineView
  • Previous by thread: Re: Log4Cocoa
  • Next by thread: Re: Allocation and disposal inside a loop
  • Index(es):
    • Date
    • Thread