Difference between revisions of "NSAutoreleasePool"

From iPhone Development Wiki
Jump to: navigation, search
(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…')
 
m
Line 21: Line 21:
 
}
 
}
 
</source>
 
</source>
 +
{{occlass|library=Foundation.framework}}

Revision as of 16:29, 21 September 2009

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