macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

NSAutoreleasePoolクラス

INDEX>Foundation> >NSAutoreleasePool

apple(OS X)

apple(iOS)

解説

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

概要

適合するプロトコル

メソッド

プールへのオブジェクトの追加

+ addObject
– addObject

サブクラス化の注意

引数

参照

例文

@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