I was trying to use segue with context on WatchKit, and i ran into this issue:
Contextual type '[Any]' cannot be used with dictionary literal
Here is the code i was using:
override func contextsForSegue(withIdentifier segueIdentifier: String) -> [Any]? {
if segueIdentifier == "One" {
return ["sceneName" : "One"]
} else if segueIdentifier == "Two" {
return ["sceneName": "Two"]
} else {
return ["sceneName": "Three"]
}
}
On the segue destination there's this code, that produces no errors:
@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)
}
}
Hope someone can help!