私のアプリでは、Webサービスからデータを取得し、uitableviewに表示していますが、問題は、mu tableviewで、取得した都市名imの後に10行(つまり、私のテーブルにあるすべての都市の都市名と緯度経度)を想定していることです。ユーザーの場所と都市の間の距離を取得しようとしているので、10回google mapAPIを呼び出す必要があります。その過程で、アプリがクラッシュします。私はNSURLRequest
ASIHttpRequest--networkQueueも使用していましたが、成功しませんでした。それで、これを行う他の方法はいくつありますか?それを修正するための他のタイプのリクエストを私に提案してください。どんな提案にも感謝します。これが私のコードです
for (NSUInteger i=0; i<[latlongarray count]; i++)
{
NSString *urlString=[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/distancematrix/json?origins=%@&destinations=%@&avoid=tolls&sensor=true",str,[latlongarray objectAtIndex:i]];
NSLog(@"%@",urlString);
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *myrequest=[[NSURLRequest alloc] initWithURL:url];
CustomConnection *distanceconnection=[[CustomConnection alloc] initWithRequest:myrequest delegate:self startImmediately:YES tag:[NSNumber numberWithInt:i]];
[distanceconnection start];
[distanceconnection release];
[myrequest release];
}
strはユーザーの場所であり、latlongarrayは都市の場所の配列です。