NSAutoreleasePool

From iPhone Development Wiki
Revision as of 16:29, 21 September 2009 by Dustin Howett (talk | contribs)

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);
}