我刚刚更新了 Xcode 的新测试版以继续开发我的 WatchKit 应用
更新我的所有 WatchKit 扩展文件后我立即收到错误
“初始化器不会覆盖其父类(super class)中的指定初始化器”
我在更新之前没有收到此错误,不确定如何解决。
有什么见解吗?
这是我的代码
class InterfaceController: WKInterfaceController {
override init(context: AnyObject?) {
// Initialize variables here.
super.init(context: context)
// Configure interface objects here.
NSLog("%@ init", self)
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
NSLog("%@ will activate", self)
}
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
NSLog("%@ did deactivate", self)
super.didDeactivate()
}
}
最佳答案
随着 Beta 3 的发布,initWithContext 现在已被弃用。您应该使用 awakeWithContext
。 WKInterfaceController 类的 init
方法现在指定为初始化程序。
引用: https://developer.apple.com/library/prerelease/ios/releasenotes/General/RN-iOSSDK-8.2/index.html ,注释部分。
关于ios - 初始化程序不会覆盖指定的初始化程序 Swift WatchKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27672222/