Passing Data Between Interfaces

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

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

Get Developing for Apple Watch, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.