我在我的VIEwController类中重写了一个名为navbarRightbuttonAction(button :)的方法.
class VIEwController: PBVIEwController { overrIDe func navbarRightbuttonAction(button: PBAdaptivebutton) { ... }}
这是我收到警告的地方:
OverrIDe of instance method 'navbarRightbuttonAction(button:)' from extension of PBVIEwController depends on deprecated inference of '@objc'
然后我认为我们的问题在PBVIEwController类中,如下所示:
extension PBVIEwController: PBNavigationbarDelegate { func navbarRightbuttonAction(button: PBAdaptivebutton) { print("OverrIDe this method") }}
所以我添加了@objc func navbarRightbuttonAction(按钮:PBAdaptivebutton),但它没有帮助.
然后我查看了PBNavigationbarDelegate协议
protocol PBNavigationbarDelegate { func navbarRightbuttonAction(button:PBAdaptivebutton)}
我添加了@objc协议PBNavigationbarDelegate,但它也没有帮助.
我不知道如何修复弃用警告.
@objc extension PBVIEwController: PBNavigationbarDelegate
有关详细信息,请查看Swift Evolution的Limiting @objc
Inference,SE-0160.它包含以下有关扩展的示例:
Enabling/disabling @objc inference within an extension
There might be certain regions of code for which all of (or none of) the entry points should be exposed to Objective-C. Allow either @objc or @nonobjc to be specifIEd on an extension. The @objc or @nonobjc will apply to any member of that extension that does not have its own @objc or @nonobjc annotation. For example:
class SwiftClass { }@objc extension SwiftClass { func foo() { } // implicitly @objc func bar() -> (Int,Int) // error: tuple type (Int,Int) not // expressible in @objc. add @nonobjc or move this method to fix the issue}@objcmembersclass MyClass : NSObject { func wibble() { } // implicitly @objc}@nonobjc extension MyClass { func wobble() { } // not @objc,despite @objcmembers}总结
以上是内存溢出为你收集整理的ios – 覆盖实例方法表单扩展取决于’@objc’的弃用推断全部内容,希望文章能够帮你解决ios – 覆盖实例方法表单扩展取决于’@objc’的弃用推断所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)