我有以下功能,我相信它正在主线程中运行(它是分配给按钮单击的事件)
-(void)startTracking:(CLLocation*) targetLocation
{
NSLog(@"Target location: %@", targetLocation);
self.locationManager = [[CLLocationManager alloc]init];
[self.locationManager setDelegate:self];
self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
self.targetRegion = [[CLRegion alloc] initCircularRegionWithCenter:targetLocation.coordinate radius:10 identifier:@"Destination Region"];
[self.locationManager startMonitoringForRegion:self.targetRegion];
//[self.locationManager startUpdatingLocation];
NSLog(@"Target region: %@", self.targetRegion);
}
我说“我认为”的唯一原因是,在它可以运行之前,我在另一个线程上运行的块中获得了 targetRegion 详细信息。
[geocoder geocodeAddressString:self.address completionHandler:^(NSArray* placemarks, NSError* error){
for (CLPlacemark* aPlacemark in placemarks)
{ // Process the placemark.
NSLog(@"Got Placemark : %@", aPlacemark);
//newDestination.destination = aPlacemark.location;
}
//self.Destination.destination = [[placemarks objectAtIndex:0] location];
self.targetLocation = [[placemarks objectAtIndex:0] location];
self.startTrackingButton.enabled = true;
self.stopTrackingButton.enabled = true;
}];
这就是没有调用代表的原因......?