我对你们有一个小的任务。我想执行选择器,其中包含函数为param。但始终遇到运行时错误。
此方法来自IAD框架。这就是我想做的:
let sel = Selector("requestAttributionDetailsWithBlock:")
if obj.responds(to: sel) {
obj.perform(sel, with: funcAsVar)
}
其中 funcAsVar
是变量的函数。请帮忙,伙计们
运行时错误是:libswiftCore.dylib-[_SwiftValue dealloc]:
您可以在传递的参数上添加@convention(block)
到perform
方法。这样:
let sel = Selector("requestAttributionDetailsWithBlock:")
if obj.responds(to: sel) {
obj.perform(sel, with: @convention(block) funcAsVar)
}