我有一个小任务要找你们。我想要执行包含函数作为参数的选择器。但总是出现运行时错误。
此方法来自 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)
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句