Core Location Best Placement and User Interruption
My application uses Core Location in three different views. It's working perfectly. In my first view, I subclass the CLLocationManager and use protocol methods for location updates to my calling class. Before I install the framework and code in my other classes, I was wondering:
Is the protocol method the best way?
What happens to the Core Location execution if the user exits the view or quits the app while it's trying to get a location fix? Is the location task terminated with the GPS system turned off im开发者_运维知识库mediately?
If the user simply switches to another view, is it OK to assume that I can start Core Location in the next view without regard to the last?
Where should the first update location call be placed. Should the application delegate instantiate the CLLocation Manager class using protocol so that it can update any of the views chosen or should each class instantiate the manager.
Any feedback would be appreciated.
Thanks.
Since you don't really need more than one CLLocationManager
, you could try creating it as an property of your application’s delegate. Then, when you load your views, in the -viewWillAppear:animated:
method of your view controller, include a [locationManager setDelegate:self];
line and it will start sending delegate messages to the currently-visible view controller.
精彩评论