Swift   发布时间:2022-03-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Swift 4.0 报错:Argument of '#selector' refers to instance method xxx大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

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

swfit 4 的新特性

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

@objcMembers
class 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所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。