argumentsRetained
起動オブジェクトは引数を保持するかを返します
解説
起動オブジェクトは引数を保持するかを返します。
初期設定は保持しません。
返り値
( BOOL )
保持するYES/NO
引数
フレームワーク
Foundation
クラス
NSInvocation
Instance Methods
使用可能
10.0
iOS2.0
例文
#import "MyObject.h" @implementation MyObject - (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 ]; //引数index2 timerControlのargに&aBuffer(つまり@"aaa")をセットする NSString *aBuffer=@"aaa"; [ invocation setArgument:&aBuffer atIndex:2]; //起動する [ invocation invoke ]; //invocationは引数や返り値を保持するか デフォルトではNO if ([invocation argumentsRetained]){ NSLog(@"YES"); }else{ NSLog(@"NO"); } } -(NSString *) timerControl:(NSString *)arg { NSLog(@"%@",arg); return @"OK"; } @end