iOS开发-简单工厂模式与OC反射机制(二)

2015-08-31 21:24:48 · 作者: · 浏览: 80
student performSelector:@selector(test1)];


6. 间接调用student的test2方法(test2有一个参数)


// - (id)performSelector:(SEL)aSelector withObject:(id)object;? ? ? ?
[student performSelector:@selector(test2:) withObject:@"123"];? ? ?
?
// 最多带两个参数? ? ? ?
//- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;


7. 延迟2s调用student的test1方法


(在命令行没有延迟效果,因为命令行执行完后就退出main函数了 ,在IOS部分main函数一直在执行,所以可以看到延迟效果)


// - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay;? ? ? ?
// delay单位为(秒)? ? ? ?
[student performSelector:@selector(test2:) withObject:@"123" afterDelay:2];