Re: newbie question on 'Cocoa Programming for Mac OS X'
Re: newbie question on 'Cocoa Programming for Mac OS X'
- Subject: Re: newbie question on 'Cocoa Programming for Mac OS X'
- From: Ondra Cada <email@hidden>
- Date: Mon, 11 Feb 2002 14:54:00 +0100
Lachlan,
>
>>>>> Lachlan O'Dea (LOD) wrote at Mon, 11 Feb 2002 16:20:55 +1100:
LOD> >In those *extremely rare* cases when the autorelease pool might
LOD> >compromise effectivity, the primary solution is
LOD> >
LOD> >NSAutoreleasePool *localPool=[[NSAutoreleasePool alloc] init];
LOD> >NSMutableArray *tempArray=[NSMutableArray array];
LOD> >... work done here ...
LOD> >[localPool release];
LOD>
LOD> Isn't this still a problem if an exception is raised? [localPool
LOD> release] would not be executed in that case.
Although technically you are right (the command would not be executed  
indeed), the contents of the pool -- including the tempArray -- *would be*  
released. Which was the exercise goal ;)
(Check autorelease pools in more deails: there is a special support there to  
release all "orphaned" pools if stack gets unwrapped -- with some slight and  
unimportant degree of imprecision you can imagine that any local pool is  
always automatically added into the pool which was current in the moment it  
was init'd.)
---
Ondra Cada
OCSoftware:     email@hidden               
http://www.ocs.cz
2K Development: email@hidden  
http://www.2kdevelopment.cz
private         email@hidden             
http://www.ocs.cz/oc
_______________________________________________
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.