我知道这很愚蠢,但我不知道我错在哪里.我是NSURLConnections的新手.我必须使用NSURLConnection下载文件.这是我的代码:
NSURL *url = [NSURL URLWithString:@"http://www.comicbookresources.com/feed.php?feed=previews"]; NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]; NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:request delegate:self startImmediately:YES ]; [self.data appendData:self.data]; NSString *filePath = [NSString stringWithFormat:@"%u/%@", NSDocumentDirectory,@"usman.pdf"]; [self.data writeToFile:filePath atomically:YES];
它看起来很荒谬,但我仍在问
编辑:对不起.我忘了添加单词:异步连接