• 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
Scope variable pattern
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scope variable pattern


  • Subject: Scope variable pattern
  • From: Yakov Zaytsev <email@hidden>
  • Date: Fri, 11 May 2007 16:10:09 +0400


Hi,

I used this pattern for ages when I was exposed to C++ world, like this obviously
struct ScopedDoing {
ScopedDoing () { /* doing.. */ }
~ScopedDoing () { /* clean up.. */ }
};
..
<some function body>
{ ScopedDoing aScopedDoing; ...
}
..


I wonder if it's possible to implement something similar with ObjC because I have several annoying places like this
{
NSAutoreleasePool *localPool;
locaPool = [[NSAutoreleasePool alloc] init];


	<body goes here>

        [localPool release];
	return noErr;
}

Yeah, I use Cocoa in carbon integration frequently..

PS
To my confusion, I haven't found any ObjC Patterns related documentation yet..


TIA

---
Yakov Zaytsev
Envion Software                        http://www.envionsoftware.com

<Talk Small and Carry a Big Class Library>





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Scope variable pattern
      • From: "Clark Cox" <email@hidden>
  • Prev by Date: Re: complex math message problem
  • Next by Date: Re: Memory space in a shared, private framework
  • Previous by thread: Re: Memory space in a shared, private framework
  • Next by thread: Re: Scope variable pattern
  • Index(es):
    • Date
    • Thread