detachDrawingThread:toTarget:withObject:
新しいオートリリースプールを作って、スレッドを実行します
+ (void)detachDrawingThread:(SEL)selector toTarget:(id)target withObject:(id)argument
class func detachDrawingThread(_ selector: Selector, toTarget target: AnyObject, withObject argument: AnyObject?)
解説
新しいオートリリースプールを作って、スレッドを実行します。
返り値
なし
引数
( SEL )selector
_ selector: Selector
( id )target
toTarget target: AnyObject
ターゲット、どのクラスのメソッドか
( id )argument
withObject argument: AnyObject?
引数となるオブジェクト
フレームワーク
ApplicationKit
クラス
NSApplication
使用可能
10.0
編集時のバージョン
10.10
参照
例文
#import "Controller.h" @implementation Controller - (IBAction)pushButton:(id)sender { //サブスレッドを作って実行する [NSApplication detachDrawingThread:@selector(action:) toTarget:self withObject:@" sub thread"]; //メインの方の処理 int i; for (i=1;i<2000;i++) { NSLog(@"main thread %d",i); } } -(void)action:(id)arg { //サブの方の処理 int i; for (i=1;i<2000;i++) { NSLog(@"%@ %d",arg,i); } } @end
//NSApplication detachDrawingThread:toTarget:withObject: @IBAction func function054(sender: AnyObject) { //共有アプリケーションインスタンスを取得 let anApplication = MyApplication.sharedApplication() // NSApplication.detachDrawingThread(Selector("methodFromFunction054:"), toTarget: self, withObject: self) } /別スレッドで動くメソッド func methodFromFunction054(info:AnyObject) { NSLog("methodFromFunction054") }