This is the first thing to do.
The following method is pro-Test available
------------------------------------------------------------
Dnlogfunc
// Initialize Location Management Objects
_locationmanager = [[cllocationmanager alloc] init];
// Request user Authorization
if ([[[[ uidevice currentdevice] systemversion] floatvalue] >= 8.0 ) {
[_locationmanager requestwheninuseauthorization];
}
// Specify the location proxy class
_locationmanager. Delegate = self;
_locationmanager. Distancefilter = +;
// turn on location services
[_locationmanager startupdatinglocation];
#pragma mark----cllocationmanagerdelegate
protocol method for locating a successful location update callback
-(void) Locationmanager: (cllocationmanager *) Manager didupdatelocations: (nsarray< cllocation *> *) Locations
{
cllocation *currentlocation = [Locations lastobject];
cllocationcoordinate2d coor = currentlocation. coordinate;
// dimension
dnlog(@ "coor.latitude==%f", coor.latitude);
// longitude
dnlog(@ "coor.longitude==%f", coor.longitude);
geo-coded classes
Clgeocoder *geocoder = [[Clgeocoder alloc] init];
anti-coding latitude and longitude points-- location information
[Geocoder reversegeocodelocation:[locations Lastobject] completionhandler:^ (Nsarray *placemarks, NSError *error) {
if (!error) {
take the last address
Clplacemark *placemark = [Placemarks lastobject];
NSString *citystr = [NSString stringwithformat:@ "%@", placemark.locality];
Dnlog (@ "citystr==%@", citystr); Remove Location City
Dnlog (@ "placemark==%@", placemark.addressdictionary);
Dnlog (@ "placemarks==%@", placemarks);
//
// }
// }];
}
iOS Apple native System location Cllocationmanager