@interface Car : NSObject
{ int year;
NSString *make;
NSString *model;
}@property (nonatomic,retain) NSString * model;
@property (nonatomic ,retain )NSString * make;
-(void) setMake:(NSString *)aMake andModel:(NSString *) aModel;
@end@implementation Car:NSObjec
t @synthesize make;
@synthesize model;
-(void) setMake:(NSString *)aMake andModel:(NSString *)aModel
{
make=aMake;
model=aModel;
}
@end
#import <Foundation/Foundation.h>
#import “Car.h”
int main (int argc, const char * argv[])
{
Car * myCar2=[[Car alloc]init];
SEL carMethod=@selector(setMake:andModel:);
[myCar2 performSelector:carMethod withObject:@"11111" withObject:@"2222" afterDelay:10];
}
这段代码中@selector 搜索setMake方法 并返回SEL类型的变量。[消息接受者 performSelector:SEL类型的变量 withObject: 第一个参数 withObject: 第二个参数 afterDelay :秒数]