How many types of URLRequest is possible in iPhone for retrieve the data from WebServices?
In my app i am retrieve data from web services and show in uitableview it is fine but problem is that in mu tableview suppose 10 row (that is city name and latitude longitude of all city that are in my table) after the retrieve city name i m trying to get Distance between user location and city so 10 times i need to call google mapAPI, in that process my app is crash.
i am using NSURLRequest
i had also used ASIHttpRequest - networkQueue but not get success.
so how many other ways to do this?
please suggest me any other types of request to fix it.
thanx for any suggestion.
here is my code
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 *myreque开发者_如何学JAVAst=[[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 is user location, and latlongarray is array for city's location.
You can go NSURLRequest operation with either synchronous or asynchronous way. According to me, dealing with NSURLRequest asynchronously is more advisable when response being is depended for further executions.
精彩评论