Çok kısaltılmış versiyon:
İlk olarak, kabul <CLLocationManagerDelegate>senin .h protokol ve #import <CoreLocation/CoreLocation.h>.
Sonra .m seferde:
- (void)viewDidLoad {
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D here = newLocation.coordinate;
NSLog(@"%f %f ", here.latitude, here.longitude);
}
Kişisel -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocationyöntem Çekirdek Yer birkaç saniyede gerçekleşmesi gereken, size söyleyecekleri var her zaman ping alacak. Bu CLLocation nesneleri doğruluğu hakkında bilgi içerirler, bu nedenle bu yöntemde iyi puan için taranabilir.
Çağırmak için emin olun [locationManager stopUpdatingLocation]ve sonra [locationManager release]bir noktada!
Kendini bulgu iyi şanslar!