O'Reilly logo

Developing for Apple Watch by Jeff Kelley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Passing Data Between Interfaces

To navigate directly to the Run Log page when a run is done, we need to call the becomeCurrentPage of our RunLogInterfaceController. When we go back to it by calling reloadRootControllersWithNames(_:contexts:), we’re just passing the name of the controller to WKInterfaceController. We don’t get back any references to the newly created interface controllers, so how can we call becomeCurrentPage?

One approach might be to use NSNotificationCenter. After we reload the controllers, we could send a notification with a short delay, then listen for that notification in our RunLogInterfaceController and call becomeCurrentPage. That would probably work, but there’s a better way. Remember the contexts parameter we were ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required