2

这段代码:

类接口控制器: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 specified initializer from its superclass” in the line override

“必须在 super.init 行中调用超类‘WKInterfaceController’的指定初始化程序”

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

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

4

2 回答 2

6

代替

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)
}

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

于 2014-12-11T02:23:16.617 回答
1

init(context: AnyObject?)不再存在。对于初始化,只需使用init,然后使用awakeWithContext从上下文初始化。

于 2014-12-10T22:21:36.557 回答