NSAutoreleasePoolクラス
INDEX>Foundation> >NSAutoreleasePool
解説
ARC(アーク:自動参照カウント)環境では@autoreleasepoolを使います。
@autoreleasepool {
// ローカルの自動開放プールのコード
}
ARCを用いてコンパイルする場合は
retain
release
autorelease
retaincount
は使えません。
継承 | NSObject |
準拠 | NSObject (NSObject) |
フレームワーク | /System/Library/Frameworks/Foundation.framework |
使用可能 | Mac OS X v10.0以降 |
IOS 2.0以降 | |
定義 | NSAutoreleasePool.h |
概要
適合するプロトコル
サブクラス化の注意
引数
参照
例文
@autoreleasepool { // ローカルの自動開放プールのコード } #import "OOOAppDelegate.h" @implementation OOOAppDelegate @synthesize window = _window; - (IBAction)myAction:(id)sender { [NSThread detachNewThreadSelector:@selector(threadTask) toTarget:self withObject:nil]; NSLog(@"%@",[[[NSThread currentThread] threadDictionary] description]); } - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { int i; //NSAutoreleasePool *pool = [NSAutoreleasePool new]; @autoreleasepool { for (i=1;i<100;i++) { NSLog(@"%d",i); } //[pool release]; } [NSThread exit]; } @end