Xcode 6.2 beta 2 WKInterfaceController watchkit 错误

标签 xcode swift watchkit

这段代码:

类接口(interface) Controller :WKInterfaceController {

@IBOutlet weak var petTable: WKInterfaceTable!

var petnames = ["Luna", "dylan", "Mery", "Mady", "Paul Newman", "heidi"]

override init(context: AnyObject?) {
    // Initialize variables here.
    super.init(context: context)

返回两个错误: “Initializer does not override a designated initializer from its superclass”行覆盖

在 super.init 行中“必须调用父类(super class)‘WKInterfaceController’的指定初始化器”

错误出现在 Xcode 6.2 beta 2(今天发布)

在之前版本的Xcode中没有错误显示

最佳答案

替换

override init(context: AnyObject?) {
    // Initialize variables here.
    super.init(context: context)

    // Configure interface objects here.


    NSLog("%@ init", self)

}

override func awakeWithContext(context: AnyObject?) {
    super.awakeWithContext(context)

    // Configure interface objects here.
    NSLog("%@ awakeWithContext", self)
}

清理你的项目,然后构建并运行

关于Xcode 6.2 beta 2 WKInterfaceController watchkit 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27411410/

相关文章:

ios - 如何在 Objective C 中将数组数据从 iPhone 传递到 Apple Watch

ios - cooking 书应用程序的自定义 iOS View

ios - Swift 最佳实践 - 使用 API 时如何/何时检查互联网连接和 404

ios - Swift countElements() 在计数标志 emoji 时返回不正确的值

swift - Core Data (Magical Record) + WatchKit Extension + Cocoa Touch Framework

watchkit - 如何将 UIGestureRecognizer 添加到 WKInterfaceImage?

ios - 为什么每次加载新的 xib 文件时?为什么它不替换以前的文件?

ios - Xcode 4.5 - 崩溃日志未符号化

ios - UIPickerView iOS 11 滚动和选择错误

ios - 视网膜屏幕的图像 (@2x)