ASIHTTPRequest
을 사용하여 간단한 라이브러리를 작성 중이며 여기서 URL을 비동기 방식으로 가져옵니다. 내 문제는 비동기 호출이 끝나기 전에 함수가 내 lib exit를 테스트하도록 작성한 main
함수입니다.ASIHTTPRequest를 통한 비동기 다운로드 테스트
Obj C 및 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.
}
그래서 비동기 호출이 완료 될 때까지 대기하는 가장 좋은 방법은 무엇입니까? 나는 잠을 자려고했지만 분명히 효과가 없습니다.
그리고 이것이 가장 좋은 아이디어입니다. – Jacek