开发者

Download a PDF file from server

开发者 https://www.devze.com 2023-01-19 09:09 出处:网络
开发者_开发百科I want to download a PDF file from my server and save it to the documents directory. I am able to do this using NSData but then the file in the documents directory is not a PDF: it\'s a

开发者_开发百科I want to download a PDF file from my server and save it to the documents directory. I am able to do this using NSData but then the file in the documents directory is not a PDF: it's an NSData object. Is there any way to download and save a straight PDF file?


NSData *pdfData = [NSData dataWithContentsOfURL:
    [NSURL URLWithString:@"http://…"]];
[pdfData writeToFile:@"…" atomically:YES];

This does not work?


The tricky part is to save the file regularly, so that you don't keep all data in memory (we only have 64MB available on iOS)

0

精彩评论

暂无评论...
验证码 换一张
取 消