Setup and Teardown
The establishMotionManager
and shutDownMotionManager
methods in Recipe 14-4 enable your application to start up and shut down the motion manager on demand. These methods are called from the application delegate when the application becomes active and when it suspends:
- (void)applicationWillResignActive:(UIApplication *)application { [tbvc shutDownMotionManager]; } - (void)applicationDidBecomeActive:(UIApplication *)application { [tbvc establishMotionManager]; }
These methods provide a clean way to shut down and resume motion services in response to the current application state.
Note
Timers in their natural state do not use a block-based API. If you’d rather use a block than callbacks ...
Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.