如何从名称中获取选择器?

时间:2021-09-07 23:40:53

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?

我有一个NSString包含我想用performSelector调用的选择器的名称。如何从字符串中获取对选择器的引用?

2 个解决方案

#2


Could use NSSelectorFromString.

可以使用NSSelectorFromString。

Probably inefficient as parameterizing a SEL is preferred.

可能低效,因为参数化SEL是首选。

#1


#2


Could use NSSelectorFromString.

可以使用NSSelectorFromString。

Probably inefficient as parameterizing a SEL is preferred.

可能低效,因为参数化SEL是首选。