扫码关注官方订阅号
如题,既然直接对一个实例发送方法名就可以调用这个方法,那为什么还要使用performSelector:去调呢?两者u有啥区别
业精于勤,荒于嬉;行成于思,毁于随。
the performSelector: method allows you to send messages that aren’t determined until runtime.
比如:
id instance = instance_from_other_module(); [instance call_undeclared_method]; // 有编译警告 [instance performSelector:@selector(call_undeclared_method)];
用这个可以避免编译警告。
此外,performSelector的其他变体功能,可以用来延时调用和跨线程调用。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
比如:
用这个可以避免编译警告。
此外,performSelector的其他变体功能,可以用来延时调用和跨线程调用。