简体   繁体   中英

Separate CLLocationManager for location & heading?

I have noticed in a few books that quite often two instances of CLLocationManager are created, one for location and a separate one for heading. If you wanted a separate delegate for each I could see the point, but all the methods are unique so I can't really think of a reason for doing this. Is there something I am missing, or is it possible to simplify this and use one CCLocationManager for both location and heading?

// LOCATION
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[customMapView setShowsUserLocation:YES];

// HEADING:
headingManager = [[CLLocationManager alloc] init];
[headingManager setDelegate: self];
[headingManager setHeadingFilter:kCLHeadingFilterNone];
[headingManager startUpdatingHeading];

I've never done this and all my apps have worked absolutely fine - I'd just use the same one for both :)

I can't even begin to think of a reason why you would do this if the delegates were the same!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM