我正在使用https://github.com/st3fan/iphone-bitly类,作为示例,我想做一些需要您帮助的事情。
- (void) demo
{
URLShortener* shortener = [[URLShortener new] autorelease];
if (shortener != nil) {
shortener.delegate = self;
shortener.login = @"LOGIN-REPLACE-ME";
shortener.key = @"KEY-REPLACE-ME";
shortener.url = [NSURL URLWithString: @"http://stefan.arentz.ca"];
[shortener execute];
///// I want to get result on here not in the delegate for further usage in my function
}
}任何帮助或建议
发布于 2011-07-28 21:41:09
你请求的东西会阻塞当前线程。如果你在主线程上运行它,你会挂起你的应用程序。由于这个原因,您链接的框架只提供了一个异步接口。
如果你已经在后台线程上运行它,你可以重新实现execute来使用[NSURLConnection sendSynchronousRequest:returningResponse:error:]。但是千万不要在你的主线程上运行它。
https://stackoverflow.com/questions/6859751
复制相似问题