Search code examples
swiftinheritanceseguewatchkit

How do I use contextForSegueWithIdentifier to include data with a push segue?


My class is class WorkoutSelectorController: WKInterfaceController {, and I define the function override func contextForSegueWithIdentifier(segueIdentifier: String) {, which all of my research says should be called automatically when a push segue is triggered so that I can set context information to be passed.

Except that it isn't. The push segue works, but doesn't call this method. Even more, I am getting the error message "Method does not override any method from its superclass", which seems to be telling me that WKInterfaceController does not contain contextForSegueWithIdentifier. But I looked in WKInterfaceController.h, and it's definitely there, so what am I doing wrong?

Why does it say the method does not exist? How do I include context information with a push segue?


Solution

  • Your function signature is wrong. The correct signature is func contextForSegue(withIdentifier segueIdentifier: String) -> Any? from the documentation.