【发布时间】:2010-05-25 07:09:42
【问题描述】:
我正在使用我正在获取的ASIHTTPRequest 编写一个简单的库
以异步方式的 URL。我的问题是我的 main 函数
在异步调用完成之前写来测试我的库退出。
我是 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.
}
那么等待异步调用完成的最佳方法是什么?我试过让睡眠,但显然不起作用。
【问题讨论】:
标签: iphone objective-c macos network-programming asihttprequest