retainArguments
起動オブジェクトが引数を保持するようにセットします
解説
起動オブジェクトが引数を保持するようにセットします。
返り値
( void )
なし
引数
フレームワーク
Foundation
クラス
NSInvocation
Instance Methods
使用可能
10.0
iOS2.0以降
参照
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { //メソッドシグネチャ NSMethodSignature *aSignature ; //起動オブジェクト NSInvocation *invocation ; //セレクタ SEL aSelector ; NSString *aBuffer=@"aaa"; //セレクタをセット aSelector = @selector( timerControl: ); //メソッドシグネチャをセット aSignature = [ self methodSignatureForSelector:aSelector ]; //起動オブジェクトを作成 invocation = [ NSInvocation invocationWithMethodSignature:aSignature ]; //ターゲットはself [ invocation setTarget: self ]; //セレクタをセット [ invocation setSelector: aSelector ]; //引数をセット [ invocation setArgument:&aBuffer atIndex:2]; //起動する [ invocation invoke ]; //引数、返り値を保持 [ invocation retainArguments]; //保持するか if ([invocation argumentsRetained]){ NSLog(@"YES"); }else{ NSLog(@"NO"); } } -(NSString *) timerControl:(NSString *)arg { NSLog(@"%@",arg); return @"OK"; } @end