What is use of performSelector in iOS

前端 未结 5 1151
不知归路
不知归路 2021-02-15 23:55

What is the role of performSelector?

Comparing:

[self btnClicked];

and

[self performSelector:@selector(btn         


        
5条回答
  •  借酒劲吻你
    2021-02-16 00:31

    PerformSelector basically allows you to decide what message to pass during runtime (late binding), as opposed to languages like plain C. If you know the name to a method in an objective C class, you can use

    NSSelectorFromString()
    

    To convert a string into a selector, and have your class call that selector using performSelector. In this way, you can choose different functions to call during runtime. You can even select which function to call using a config file.

提交回复
热议问题