我想通过使用NSURLConnection的HTTP获取图像。我在后台执行选择iOS的ObjC网络和选择器在后台
[self performSelectorInBackground:@selector(loadingDaemon) withObject:nil];
,我做这个
NSString *fullImageURL = [NSString stringWithFormat:@"http://%@/%@", baseURL, currentlyLoadingImage];
NSURL *imgURL = [NSURL URLWithString:fullImageURL];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:imgURL];
request.timeoutInterval = 10;
NSURLConnection *newConnection = [NSURLConnection connectionWithRequest:request delegate:self];
我设置NSURLConnection的”授人以自我和实现方法
connection:didReceiveResponse:
connection:didReceiveData:
connection:didFailWithError:
connectionDidFinishLoading:
此外,我记录每一个方法调用和条件分支。但是上面的4个函数从来都不会被调用。请你能解释我为什么?
我怀疑你正在创建的URL包含特殊字符而没有被转义,所以它是无效的。 – 2012-08-29 20:05:15
如果在方法结束时说'[[NSRunLoop currentRunLoop]运行]'会发生什么? –
只是你知道,使用NSURLConnection的异步加载的一个主要原因是你可以在主线程上完成所有这些工作,而不必将其作为背景。 –