其实 就是 多线程 或者线程锁 当然可能会有人用监听,这里只是给一种解决办法 嘿嘿
- (CLPlacemark*)getStartplacemark{//先创建一个semaphoredispatch_queue_t queue = dispatch_get_global_queue(0, 0);dispatch_semaphore_t semaphore = dispatch_semaphore_create(1); __block CLPlacemark* start; [self.geoCoder geocodeAddressString:_SourceText.text completionHandler:^(NSArray *placemarks, NSError *error) { CLPlacemark *startPlaceMark = [placemarks firstObject]; start = startPlaceMark; //发出已完成的信号 dispatch_semaphore_signal(semaphore); }]; //等待执行,不会占用资源 dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); return start;}?
时间: 2024-10-15 16:32:52