リクエストを送信するネストループがあります。NSURLConnectionはすべてのプロセスを完了した後にリクエストを送信します
-(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ループを終了し、すべての要求を"-(void) connectionDidFinishLoading:(NSURLConnection *) connection"
に入力する前に送信します。
[NSURLConnection sendSynchronousRequest:request returningResponse:レスポンスエラー:なし] –
addDependencyまたはMaxConcurrentOperationを指定してNSOperationQueueを使用することができます(この場合、一般的なアドバイスも適用されます)。 –
@PKTあなたの解決策は私にとっては十分だと思います。ありがとう – user1151874