3 string function selector swift
我做了一个接收字符串的函数。该字符串必须转换为函数名称,然后作为#selector参数传递。我试过了,但是没有用:
func setFunctionWithTap(functionName: String) {
let tap = UITapGestureRecognizer(target: self, action: #selector(functionName))
...
}
Run Code Online (Sandbox Code Playgroud)
你能告诉我是否有可能吗?
let tap = UITapGestureRecognizer(target: self, action: Selector(functionName))
Run Code Online (Sandbox Code Playgroud)