Adding Lifecycle Methods
The lifecycle methods of WKExtensionDelegate and UIApplication (on iOS) protocols are similar, though they are fewer. The most common one to implement is applicationDidFinishLaunching, allowing you to do setup when the app is launched. The other two have you covered when the app is interrupted—for example, if the user gets a call in the middle of a run. First, applicationWillResignActive will be called on your delegate, allowing you to save your work, and then applicationDidBecomeActive lets you restore it once the app is back in the foreground.
The WatchKit extension lifecycle methods are shown here in the context of launching a WatchKit app. You see the state of the app from before it’s launched to when it’s running ...
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