0
我试图用赛格瑞与WatchKit背景下,我就遇到了这个问题:任何不能与字典文字使用
语境型“[任何]”不能用字典文字
使用
这里是我使用的代码:
override func contextsForSegue(withIdentifier segueIdentifier: String) -> [Any]? {
if segueIdentifier == "One" {
return ["sceneName" : "One"]
} else if segueIdentifier == "Two" {
return ["sceneName": "Two"]
} else {
return ["sceneName": "Three"]
}
}
在SEGUE目的地有这个代码,产生任何错误:
@IBOutlet var theName: WKInterfaceLabel!
override func awake(withContext context: Any?) {
super.awake(withContext: context)
// Configure interface objects here.
self.setTitle("")
let dict = context as? NSDictionary
if dict != nil {
let segueContext = dict![["sceneName"]] as! String
theName.setText(segueContext)
}
}
希望有人能帮助!