CLLocationManager を使用して現在の場所を特定しています。
- (void)viewDidLoad
{
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
self.currentLocation = newLocation;
NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow];
if (locationAge > 5.0) return;
if (newLocation.horizontalAccuracy < 0) return;
if (self.currentLocation == nil || self.currentLocation.horizontalAccuracy > newLocation.horizontalAccuracy) {
self.currentLocation = newLocation;
}
[locationManager stopUpdatingLocation];
}
iOS 5.1 シミュレーターでは動作しますが、iOS 4.3 シミュレーターでは動作しません。iOS 5.1 より前の実際のデバイスでは問題になる可能性があると思います。なぜ機能しないのですか?