MKLocalSearchResponse *response, NSError *error){ if (++x == 2) { [self finish]; } }; [[[MKLocalSearch alloc] initWithRequest:rq1] startWithCompletionHandler:completionHandler]; [[[MKLocalSearch alloc] initWithRequest :rq2] startWithCompletionHandler:completionHandler];复制代码 这里就可以使用when来优雅的处理这种情况: id search1 = [[[MKLocalSearch alloc] initWithRequest:rq1] promise]; id search2 = [[[MKLocalSearch alloc] initWithRequest:rq2] promise id coffeeSearch = [[MKLocalSearch alloc] initWithRequest:rq1]; id beerSearch = [[MKLocalSearch alloc]
//设置检索参数 req.region=region; //兴趣点关键字 req.naturalLanguageQuery=@"hotal"; //初始化检索 MKLocalSearch * ser = [[MKLocalSearch alloc]initWithRequest:req]; //开始检索,结果返回在block中 [ser startWithCompletionHandler