【发布时间】:2013-03-28 06:12:16
【问题描述】:
我有一个来自服务器的pdf 文件。
然后我需要将文件加载到 NSDocument 目录路径并且它工作正常,但我想显示 UIProgressView 以存储每个字节。如何做到这一点,请帮助我
提前致谢
我尝试这样存储:
NSError *error;
NSArray *ipaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *idocumentsDir = [ipaths objectAtIndex:0];
NSString *idataPath = [idocumentsDir stringByAppendingPathComponent:@"File"];
NSLog(@"idataPath:%@",idataPath);
//Create folder here
if (![[NSFileManager defaultManager] fileExistsAtPath:idataPath])
{
[[NSFileManager defaultManager] createDirectoryAtPath:idataPath withIntermediateDirectories:NO attributes:nil error:&error];
}
// Image Download here
NSString *fileName = [idataPath stringByAppendingFormat:@"/image.jpg"];
NSLog(@"imagePathDOWNLOAD:%@",fileName);
NSData *pdfData1 = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[URLArray objectAtIndex:a]]];
[pdfData1 writeToFile:fileName atomically:YES];
【问题讨论】:
-
从 Web URL 下载或存储在 Documents 中时需要进度吗?
-
存储在文档中时
标签: iphone byte store uiprogressview nsdocumentdirectory