我正在尝试从网址下载图像和音频文件..我想将下载的文件保存在特定路径中是否可能..
请建议我......
谢谢......
答案 0 :(得分:3)
将文件保存在应用的文档目录中。
NSString *documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *path = [documentsDirectoryPath stringByAppendingPathComponent:@"myfile.mp3"];
BOOL success = [myMp3Data writeToFile:path atomically:YES];
答案 1 :(得分:1)
是的,有可能。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath2 = [NSString stringWithFormat:@"%@/%@.jpg", documentsDirectory, fileName];
NSData* imageData = UIImageJPEGRepresentation(drawImage.image, 1.0);
[imageData writeToFile:filePath2 atomically:NO];