Difference between revisions of "IconSupport"
(New How to use this library format.) |
|||
Line 1: | Line 1: | ||
− | + | The NSAutoreleasePool class is a thin wrapper around the '''NSPushAutoreleasePool''' and '''NSPopAutoreleasePool''' functions. | |
− | |||
− | |||
− | |||
− | |||
− | ''' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<source lang="objc"> | <source lang="objc"> | ||
− | # | + | #ifdef __cplusplus |
+ | extern "C" { | ||
+ | #endif | ||
+ | void *NSPushAutoreleasePool(NSUInteger capacity); | ||
+ | void NSPopAutoreleasePool(void* token); | ||
+ | #ifdef __cplusplus | ||
+ | } | ||
+ | #endif | ||
</source> | </source> | ||
− | + | Example: | |
− | + | <source lang="objc"> | |
− | + | static void MyMethod() | |
− | + | { | |
− | + | void *pool = NSPushAutoreleasePool(0); | |
− | + | [[[NSObject alloc] init] autorelease]; | |
− | + | NSPopAutoreleasePool(pool); | |
− | <source lang=" | ||
− | |||
− | |||
− | |||
} | } | ||
</source> | </source> | ||
− | + | The "capacity" argument of NSPushAutoreleasePool only serves as a hint. It is unused in the current implementation. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | {{occlass|library=Foundation.framework}} |
Revision as of 09:43, 2 February 2017
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.