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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access