Difference between [self MethodName] and [self performSelector:@selector(Method Name)]

给你一囗甜甜゛ 提交于 2019-12-23 07:38:23

问题


What is the difference between calling the methods with following types

1.

[self methodName];

and

2.

[self performSelector:@selector(methodName)];   // no afterDelay is used

Is it like performSelector will use different thread to work??


回答1:


In most cases, they are equivalent.

According to the documentation, the purpose of the performSelector: variant is so that you can call methods that are defined dynamically and not actually present at compile-time. That's all. For calling a method that is present at compile-time, there is no difference between the two.



来源:https://stackoverflow.com/questions/7445337/difference-between-self-methodname-and-self-performselectorselectormethod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!