如何从服务器下载文件?
有没有办法将pdf文件从网络服务发送到 iPhone ?
是否有必要将pdf转换为任何其他形式,然后发送它还重新转换它?
答案 0 :(得分:1)
您可以使用以下代码轻松下载PDF文件
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:downloadUrl]];
//Store the Data locally as PDF File
NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
NSString *pdf1;
pdf1 = [NSString stringWithFormat:@"%@.pdf",yourBookTitle];
NSString *filePath = [resourceDocPath stringByAppendingPathComponent:pdf1];
[pdfData writeToFile:filePath atomically:YES];
第二个问题将您的pdf文件存储到服务器并获取Url无需以任何格式转换