How do I get a selector from its name?

2020-04-04 07:01发布

问题:

I have an NSString containing the name of a selector I would like to call with performSelector. How can I get a reference to the selector from the string?

回答1:

NSSelectorFromString(name)



回答2:

Could use NSSelectorFromString.

Probably inefficient as parameterizing a SEL is preferred.