私はあなたが間違った方法でそれを行っていると思います.ブロックする理由はありません.あなたがしなければならないことは、そのメソッドがvoidを返すようにすることです.ジオコーディングを処理しているクラスでは、-( void)didReceivePlacemark:(id)placemark, placemark は nil または何らかの目印にすることができ、ジオコーダーが戻ったときに呼び出されます。また、クラスのデリゲート プロパティを作成して、誰でもプロトコルをサブスクライブできるようにします...次に、呼び出し元のクラスでプロトコルをサブスクライブし、メソッドを実装します...プロトコルについてもう少し詳しく説明します
役立つことを願っています ここに例があります: したがって、ジオコーディングを行うクラスのインターフェースは次のようになります
@protocol GeocoderControllerDelegate
-(void)didFindGeoTag:(id)sender; // this is the call back method
@end
@interface GeocoderController : NSObject {
id delegate;
}
@property(assign) id <GeocoderControllerDelegate> delegate;
次に、実装では、次のようなものが表示されます
- (void) getAddress:(CLLocationCoordinate2D) coordinate
{
[self startGeocoder:coordinate];
}
- (void)reverseGeocoder:(MKReverseGeocoder*)geocoder didFindPlacemark:(MKPlaseMark*)plasemark
{
[delegate didFindGeoTag:plasemark];
}
- (void)reverseGeocoder:(MKReverseGeocoder*)geocoder didFailWithError:(NSError*)error
{
[delegate didFindGeoTag:nil]
}
呼び出しクラスでは、GeocoderClass のデリゲート プロパティを設定し、プロトコルを実装するだけで済みます。実装は次のようになります。
-(void)findMethod
{
GeocoderController *c=...
[c setDelegate:self];
[c findAddress];
//at this point u stop doing anything and just wait for the call back to occur
//this is much preferable than blocking
}
-(void)didFindGeoTag:(id)sender
{
if(sender)
{
//do something with placemark
}
else
{
//geocoding failed
}
}