ASIHTTPRequest
非同期でURLを取得する場所を使用して単純なライブラリを作成しています。私の問題はmain
、非同期呼び出しが終了する前に、libをテストするために作成した関数が終了することです。
私はObjCとiPhoneの開発に非常に慣れていませんが、メイン機能ですべてのリクエストが完了するまで待つ良い方法を誰かが提案できますか?
現在、私のmain
関数は次のようになっています-
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
IBGApp *ibgapp = [[IBGApp alloc] init];
IBGLib *ibgl = [[IBGLib alloc] initWithUsername:@"joe" andPassword:@"xxx"];
// The two method calls below download URLs async.
[ibgl downloadURL:@"http://yahoo.com/" withRequestDelegate:ibgapp andRequestSelector:@selector(logData:)];
[ibgl downloadURL:@"http://google.com/" withRequestDelegate:ibgapp andRequestSelector:@selector(logData:)];
[pool release];
return 0; // I reach here before the async calls are done.
}
では、非同期呼び出しが完了するまで待つための最良の方法は何ですか?寝てみましたが、明らかにうまくいきません。