您好我正在尝试创建一个 NSOperaion 队列来下载一堆 PDF 文件。但它不起作用。NSURLConnection 没有调用委托方法,因为我将它们放在 NSOperation 队列中......任何替代方法或解决方案???
- (void) loadData {
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation;
for(int i=0;i<[self.pdfArray count];i++){
NSString *url = [NSString stringWithFormat:@"http://www.somelink.com/%@.pdf",[self.pdfArray objectAtIndex:i]];
operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(loadDataWithOperation:)
object:url];
[queue addOperation:operation];
[operation release];
}
}
- (void) loadDataWithOperation:(NSString *) url{
// Create the request.
NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:url]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
NSURLConnection *theDownload = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES];
}