• 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
Re: newbie question on 'Cocoa Programming for Mac OS X'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie question on 'Cocoa Programming for Mac OS X'


  • Subject: Re: newbie question on 'Cocoa Programming for Mac OS X'
  • From: "Erik M. Buck" <email@hidden>
  • Date: Mon, 11 Feb 2002 08:49:56 -0600
  • Organization: EMB & Assocites Inc.

Autorelease pools are always nested and will be released when their parent
pool is released.

----- Original Message -----
From: "Lachlan O'Dea" <email@hidden>
To: <email@hidden>
Sent: Sunday, February 10, 2002 11:20 PM
Subject: Re: newbie question on 'Cocoa Programming for Mac OS X'


> At 16:53 +0100 09/02/2002, Ondra Cada wrote:
> >So far as I see, just one: the buggy pattern is
> >
> >RC> NSMutableArray *tempArray=[[NSMutableArray alloc]init];
> >RC> ... work done here ...
> >RC> [tempArray release];
> >
> >since if "work" happened to raise an exception, tempArray would leak. The
> >proper pattern is
> >
> >NSMutableArray *tempArray=[NSMutableArray array];
> >... work done here ...
> >
> >(and it is even nicer and more convenient).
> >
> >In those *extremely rare* cases when the autorelease pool might
compromise
> >effectivity, the primary solution is
> >
> >NSAutoreleasePool *localPool=[[NSAutoreleasePool alloc] init];
> >NSMutableArray *tempArray=[NSMutableArray array];
> >... work done here ...
> >[localPool release];
>
> Isn't this still a problem if an exception is raised? [localPool
> release] would not be executed in that case.
>
> --
> Lachlan O'Dea <email@hidden> Computer Associates Pty Ltd
> Webmaster Vet - Anti-Virus Software
> http://www.vet.com.au/
> _______________________________________________
> 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.
_______________________________________________
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.

References: 
 >newbie question on 'Cocoa Programming for Mac OS X' (From: Richard Chamberlain <email@hidden>)
 >Re: newbie question on 'Cocoa Programming for Mac OS X' (From: "Lachlan O'Dea" <email@hidden>)

  • Prev by Date: Re: toolbar and switching a NSView
  • Next by Date: Re: Getting hold of an NSView from an NSDocument
  • Previous by thread: Re: newbie question on 'Cocoa Programming for Mac OS X'
  • Next by thread: Re: newbie question on 'Cocoa Programming for Mac OS X'
  • Index(es):
    • Date
    • Thread