1_locationmanager =[[Cllocationmanager alloc] init];2 3 //the desired longitude4 5_locationmanager.desiredaccuracy =kcllocationaccuracybest;6 7 //change about 100 m update once8 9_locationmanager.distancefilter = -;Ten One //Certified Nslocationalwaysusagedescription A - if([[Uidevice Currentdevice] Systemversion].doublevalue >8.0) {//if iOS is 8.0 or later - the if([_locationmanager respondstoselector: @selector (requestalwaysauthorization)]) {//the Requestalwaysauthorization method is available in the Location management object - - //Run - + [_locationmanager requestalwaysauthorization]; - + } A at } - -_locationmanager.Delegate=Self ; - - [_locationmanager startupdatinglocation]; - in - to //get latitude and longitude and detailed address + -- (void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (nsarray<cllocation *> *) Locations { the * $ Panax NotoginsengCllocation *location =[Locations Lastobject]; - theNSLog (@"Latitude = = =%g Longitude = = =%g", Location.coordinate.latitude, location.coordinate.longitude); + A the + //Reverse geocoding - $Clgeocoder *clgeocoder =[[Clgeocoder alloc] init]; $ -Cllocation *CL =[[Cllocation alloc] InitWithLatitude:location.coordinate.latitude longitude:location.coordinate.longitude]; - the[Clgeocoder reversegeocodelocation:cl Completionhandler: ^ (Nsarray *placemarks,nserror *error) { - Wuyi for(Clplacemark *placemarkinchplacemarks) { the - Wu -Nsdictionary *addressdic =placemark.addressdictionary; About $ - -NSString *state=[addressdic Objectforkey:@" State"]; - ANSString *city=[addressdic Objectforkey:@" City"]; + theNSString *sublocality=[addressdic Objectforkey:@"sublocality"]; - $NSString *street=[addressdic Objectforkey:@"Street"]; the the the theNSLog (@"City ====%@%@%@%@", state, City, Sublocality, street); - in [_locationmanager stopupdatinglocation]; the the } About the }]; the the } + -
Get the latitude and longitude of iOS and get a detailed address by reverse geocoding