NSAutoreleasePool

From iPhone Development Wiki
Revision as of 16:20, 21 September 2009 by Rpetrich (talk | contribs) (Created page with 'The NSAutoreleasePool class is a thin wrapper around the NSPushAutoreleasePool and NSPopAutoreleasePool functions. <source lang="objc"> #ifdef __cplusplus extern "C" void *NSPus…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The NSAutoreleasePool class is a thin wrapper around the NSPushAutoreleasePool and NSPopAutoreleasePool functions.

#ifdef __cplusplus
extern "C" void *NSPushAutoreleasePool(void *);
extern "C" void NSPopAutoreleasePool(void *);
#else
void *NSPushAutoreleasePool(void *);
void NSPopAutoreleasePool(void *);
#endif

Example:

static void MyMethod()
{
    void *pool = NSPushAutoreleasePool(NULL);
    [[[NSObject alloc] init] autorelease];
    NSPopAutoreleasePool(pool);
}