2013/02/03

iOS6でdidUpdateToLocationが使えなくなった件

(English text is available below.)

iOS6から CoreLocation の didUpdateToLocation が使えなくなったらしい。
didUpdateLocations を使えと言われるが
なんか引数がちがう。
- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
- (void)locationManager:(CLLocationManager *)manager
     didUpdateLocations:(NSArray *)locations
didUpdateToLocation の newLocation は
[locations lastObject] でとれるらしい。
- (void) locationManager:(CLLocationManager *)manager
      didUpdateLocations:(NSArray *)locations{
    CLLocation *newLocation = [locations lastObject];
}
のようにすると newLocation がとれるんだって。


              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(I've added English translated text for some traffic from US.)


 "didUpdateToLocation" method has been obsolete from iOS6.
Alternatively "didUpdateLocations" has been available but parameters are different.
- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
- (void)locationManager:(CLLocationManager *)manager
     didUpdateLocations:(NSArray *)locations
When you want "newLocation" in "didUpdateToLocation", you can use [locations lastObject] like below.
- (void) locationManager:(CLLocationManager *)manager
      didUpdateLocations:(NSArray *)locations{
    CLLocation *newLocation = [locations lastObject];
}
Related Posts Plugin for WordPress, Blogger...