target
起動オブジェクトのターゲットを返します
解説
起動オブジェクトのターゲットを返します。
返り値
( id )
ターゲットオブジェクト
引数
フレームワーク
Foundation
クラス
NSInvocation
Instance Methods
使用可能
10.0
参照
例文
#import "MyObject.h" @implementation MyObject NSTimer *timer=nil; - (IBAction)myAction:(id)sender { //メソッドシグネチャ NSMethodSignature *aSignature ; //起動オブジェクト NSInvocation *invocation ; //セレクタ SEL aSelector ; //セレクタをセット aSelector = @selector( timerControl ); //メソッドシグネチャをセット aSignature = [ self methodSignatureForSelector:aSelector ]; //起動オブジェクトをセット invocation = [ NSInvocation invocationWithMethodSignature:aSignature ]; //ターゲットはself [ invocation setTarget: self ]; //セレクタをセット [ invocation setSelector: aSelector ]; //ターゲット NSLog([[invocation target] className]); //タイマーで呼び出し timer = [NSTimer scheduledTimerWithTimeInterval:1 invocation:invocation repeats:YES]; } -(void) timerControl{ NSLog(@"..."); } @end