2014-12-10 101 views
2

此代码:的Xcode 6.2 Beta 2的WKInterfaceController watchkit错误

类InterfaceController: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) 

返回两个错误: 在线路覆盖 “初始值不从它的超重写指定初始化” “

”必须调用super.init中超类'WKInterfaceController'''的指定初始值设定项“

错误是在Xcode 6.2测试版2(今天发布)

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

回答

1

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

+1

我想请教一下beta版类似这样的问题在苹果开发者论坛,因为它们是NDA安全。 – macshome 2014-12-10 22:33:04

+3

WatchKit API和文档已公开发布。您无需使用已接受NDA的Apple dev帐户登录即可阅读API文档。 – 2014-12-10 22:58:02

+0

啊!我还没有意识到文档没有登录就可以使用。这是需要帐户的SDK和工具的下载。谢谢。 – macshome 2014-12-11 21:57:20

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

清理项目,然后生成并运行