methodSignature
起動オブジェクトのメソッドシグネチャを返します
解説
起動オブジェクトのメソッドシグネチャを返します。
メソッドシグネチャとは、引数と返り値のセット
たとえば-(BOOL)updateAppointmentsForDate:(Date *)aDateというメソッドの場合
メソッドシグネチャはBOOLとDate *
引数
フレームワーク
Foundation
クラス
NSInvocation
Instance Methods
使用可能
10.0
iOS2.0
参照
例文
#import "MyObject.h" @implementation MyObject NSTimer *timer=nil; - (IBAction)myAction:(id)sender { //メソッドシグネチャ NSMethodSignature *aSignature ; //起動オブジェクト NSInvocation *invocation ; //セレクタ SEL aSelector = @selector( timerControl: ); //メソッドシグネチャ aSignature = [ self methodSignatureForSelector:aSelector ]; //起動オブジェクトをセット invocation = [ NSInvocation invocationWithMethodSignature:aSignature ]; //ターゲットはself [ invocation setTarget: self ]; //セレクタをセット [ invocation setSelector: aSelector ]; //起動する [ invocation invoke ]; NSLog(@"Signature number %d",[[invocation methodSignature] numberOfArguments]); NSLog(@"Signature 2'sType %s",[[invocation methodSignature] getArgumentTypeAtIndex:2]); } -(void) timerControl:(NSString *)string { NSLog(@"..."); } @end