setReturnValue:
起動オブジェクトの戻り値をバッファに入れます
-(void)setReturnValue:(void *)buffer:
解説
起動オブジェクトの戻り値をバッファに入れます。
返り値
( void )
なし
引数
( void * )buffer
バッファのポインタ
フレームワーク
Foundation
クラス
NSInvocation
Instance Methods
使用可能
10.0
iOS2.0
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { //メソッドシグネチャ NSMethodSignature *aSignature ; //起動オブジェクト NSInvocation *invocation ; //セレクタ SEL aSelector = @selector( timerControl: ); //セットする引数の値 NSString *aBuffer=@"argument"; NSString *ret = [[[NSString alloc] init] autorelease]; NSString *theString = @"NG"; //メソッドシグネチャをセット aSignature = [ self methodSignatureForSelector:aSelector ]; //起動オブジェクトをセット invocation = [ NSInvocation invocationWithMethodSignature:aSignature ]; //ターゲットはself [ invocation setTarget: self ]; //セレクタをセット [ invocation setSelector: aSelector ]; //引数に値をセット [ invocation setArgument:&aBuffer atIndex:2]; //保持する [ invocation retainArguments ]; //起動 [ invocation invoke ]; //返り値を取り出す [ invocation getReturnValue:&ret]; NSLog(ret); //返り値にセットする [ invocation setReturnValue:&theString]; //返り値を取り出す [ invocation getReturnValue:&ret]; NSLog(ret); } -(NSString *) timerControl:(NSString *)arg { NSLog(@"%@",arg); return @"OK"; } @end