mNo edit summary |
m (the argument of NSPushAutoreleasePool is an unsigned integer, not a pointer. See -[NSAutoreleasePool initWithCapacity:].) |
||
Line 1: | Line 1: | ||
The NSAutoreleasePool class is a thin wrapper around the NSPushAutoreleasePool and NSPopAutoreleasePool functions. | The NSAutoreleasePool class is a thin wrapper around the '''NSPushAutoreleasePool''' and '''NSPopAutoreleasePool''' functions. | ||
<source lang="objc"> | <source lang="objc"> | ||
#ifdef __cplusplus | #ifdef __cplusplus | ||
extern "C" void *NSPushAutoreleasePool( | extern "C" { | ||
#endif | |||
# | void *NSPushAutoreleasePool(NSUInteger capacity); | ||
void NSPopAutoreleasePool(void* token); | |||
#ifdef __cplusplus | |||
} | |||
#endif | #endif | ||
</source> | </source> | ||
Line 16: | Line 17: | ||
static void MyMethod() | static void MyMethod() | ||
{ | { | ||
void *pool = NSPushAutoreleasePool( | void *pool = NSPushAutoreleasePool(0); | ||
[[[NSObject alloc] init] autorelease]; | [[[NSObject alloc] init] autorelease]; | ||
NSPopAutoreleasePool(pool); | NSPopAutoreleasePool(pool); | ||
} | } | ||
</source> | </source> | ||
The "capacity" argument of NSPushAutoreleasePool only serves as a hint. It is unused in the current implementation. | |||
{{occlass|library=Foundation.framework}} | {{occlass|library=Foundation.framework}} |
Latest revision as of 17:25, 21 September 2009
The NSAutoreleasePool class is a thin wrapper around the NSPushAutoreleasePool and NSPopAutoreleasePool functions.
#ifdef __cplusplus
extern "C" {
#endif
void *NSPushAutoreleasePool(NSUInteger capacity);
void NSPopAutoreleasePool(void* token);
#ifdef __cplusplus
}
#endif
Example:
static void MyMethod()
{
void *pool = NSPushAutoreleasePool(0);
[[[NSObject alloc] init] autorelease];
NSPopAutoreleasePool(pool);
}
The "capacity" argument of NSPushAutoreleasePool only serves as a hint. It is unused in the current implementation.