私は、非同期ダウンロードの処理方法や実際には一連のイベントを持つプログラムに関する基本的なアーキテクチャ上の質問があり、以前のイベントが終了するまで各イベントが開始されません。iphone Asynch複数のプロセスをダウンロードして処理する
データをダウンロードしてからダウンロードが完了した後でアクションを実行する場合は、その間に(進捗インジケータ、スプラッシュ画面などを表示するなど)何か他の操作を行いたい場合は、そのようなプログラムを設計することは意味:
-(void)thisMethodStartsTheDownloading{
//start the download using NSURLConnection (I'm fine with these details)
//show a UIView for a splash screen image or do anything else you want to do
}
-(void)thisMethodRunsWhenDownloadIsFinished{
//hide or remove the splash screen (if applicable)
//do whatever I need to do with the downloaded data
//this method does not run on its own unless called when NSURLConnection is done
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
//do whatever I need to do with my downloaded data
[self performSelector:@selector(thisMethodRunsWhenDownloadIsFinished)];
// or [self thisMethodRunsWhenDownloadIsFinished];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
//incrementally appendData as it comes in from the download process
[receivedData appendData:data];
}
私は、各メソッドが完了するなどの方法の間の周りにジャンプし、プログラムの構造を理解していることを確認します。
基本的に、私はあなたがプロセスのチェーンを持っているが、前のチェーンが終了しない限り、そのチェーンの各部分が動くことができないと仮定します。現在のチェーンが終了したときにチェーン内の次のチェーンを呼び出すことによって、それらのチェーンを互いに向けることができます。これは理想的な/標準的な方法ですか?
助けてくれてありがとう – johnbakers