我是 iphone 开发的新手,有人可以帮我解决这个问题吗,从一周开始我就面临一个问题,那就是我有多个网址,如下所示
for (int i=0;i<=[listingAffArray];i++)
NSString *urlStr=[NSString stringWithFormat:@"http://demo.holidayjuggle.net:7777/services/inventoryservice/%@/%@/stores/search?location=12.971598700000000000,77.594562699999980000,50",appDelegate.buyingAff,[appDelegate.listingAffArray objectAtIndex:i]];
}
在这我得到了所有 url 的响应,但是在 didfinishloading 中无法找到哪些 url 响应数据
NSURL *url=[NSURL URLWithString:urlStr];
NSMutableURLRequest *req=[NSMutableURLRequest requestWithURL:url];
[req setHTTPMethod:@"GET"];
[req setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
connection=[NSURLConnection connectionWithRequest:req delegate:self];
if(connection){
NSLog(@"connection is successfull ");
}
else{
NSLog(@"connection failed");
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
responseData=[[NSMutableData alloc]init];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[responseData appendData:data];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *strResponse=[[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
}
在 responsedata 中只有最后一个 url 数据我放了断点并观察到每个 url 在 didfinishloading 中调用,当第二个 url 调用时,它正在使用 secondurl 调用更新,就像在 responsedata 中最后一个 url 数据一样。如何存储每个响应数据分别
提前致谢
西瓦库马里