1.[selfperformSelector:@selector(removeAlert:)withObject:alertafterDelay:2];
带一个参数的方法 ,延迟2s后执行
2.- (void)removeAlert:(UIAlertController *)alertView
{
[alertView dismissViewControllerAnimated:YEScompletion:nil];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations
{
NSLog(@"locations is %@",locations);
CLLocation *location = [locations lastObject];
myGeocoder = [[CLGeocoder alloc] init];
[myGeocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error)
{
if(error == nil && [placemarks count]>0)
{
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSLog(@"name = %@",placemark.name);
NSLog(@"Country = %@", placemark.country);
NSLog(@"Postal Code = %@", placemark.postalCode);
NSLog(@"locality = %@", placemark.locality);
NSLog(@"subLocality = %@", placemark.subLocality);
NSLog(@"address = %@",placemark.name);
NSLog(@"administrativeArea = %@",placemark.administrativeArea);
NSLog(@"subAdministrativeArea = %@",placemark.subAdministrativeArea);
NSLog(@"ISOcountryCode = %@",placemark.ISOcountryCode);
NSLog(@"thoroughfare = %@", placemark.thoroughfare);
NSLog(@"subThoroughfare = %@",placemark.subThoroughfare);
// [label setText:[NSString stringWithFormat:@"address is: %@",placemark.name]];
label = [NSString stringWithFormat:@"%@",placemark.name];
}
else if(error==nil && [placemarks count]==0){
NSLog(@"No results were returned.");
}
else if(error != nil) {
NSLog(@"An error occurred = %@", error);
}
}];
[self.locMgr stopUpdatingLocation];
}