Swift 4.0 报错:Argument of '#selector' refers to instance method xxx

Swift 4.0 报错:Argument of '#selector' refers to instance method xxx,第1张

概述swfit 4 的新特性 今天编译代码发现了这个问题,查了下,修正很简单在相关类前加: @objcMembersclass JKWLoginVC: UIViewController {} 或者在方法名前做修改 @objc func clickLoginBtn() { } As of Swift 4 you’ll start seeing the error “Argument of

swfit 4 的新特性

今天编译代码发现了这个问题,查了下,修正很简单在相关类前加:

@objcmembersclass JKWLoginVC: UIVIEwController {}

或者在方法名前做修改

@objc func clickLoginBtn() {    }

As of Swift 4 you’ll start seeing the error “Argument of ‘#selector’ refers to instance method ‘firstPage()’ that is not exposed to Objective-C”,along with the proposed fix of “Add ‘@objc’ to expose this instance method to Objective-C”. What this means is that the Swift method in question isn’t visible to Objective-C,which matters because UIbarbuttonItem is Objective-C code.

While adding @objc to indivIDual methods is a working solution,I expect most people will just shrug their shoulders and put @objcmembers before their class – that automatically exposes everything in the class to Objective-C,just like Swift 3 used to. So,modify the class deFinition to this:

总结

以上是内存溢出为你收集整理的Swift 4.0 报错:Argument of '#selector' refers to instance method xxx全部内容,希望文章能够帮你解决Swift 4.0 报错:Argument of '#selector' refers to instance method xxx所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1057604.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存