我有一个发送请求的嵌套循环。
-(void) download
{
for(NSString *id in array)
{
//init with request and start the connection
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request deletegate:self];
[conn start];
}
}
-(void) connection:(NSURLConnection *) connection didReceiveData:(NSData *) data
{
//enter here secondly
}
-(void) connectionDidFinishLoading:(NSURLConnection *) connection
{
//enter here last, after finish the for loop
//my intention is use the downloaded data to do something before sending a new request.
}
问题是我想"-(void) connectionDidFinishLoading:(NSURLConnection *) connection"
在 for 循环中再次发送请求之前先输入。
但目前它将完成 for 循环并在 enter 之前将所有请求发送到"-(void) connectionDidFinishLoading:(NSURLConnection *) connection"
.