What is use of performSelector in iOS

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

What is the role of performSelector?

Comparing:

[self btnClicked];

and

[self performSelector:@selector(btn         


        
5条回答
  •  野的像风
    2021-02-16 00:42

    The two are pretty identical when used as you have demonstrated, but the latter has the advantage that you can dynamically determine which selector to call at runtime.

    SEL selector = [self gimmeASelectorToCall];
    [self performSelector: selector];
    

    [Source]

提交回复
热议问题