0

如何从 ios 6.0 sdk 中大约 5mb 大小的 url 下载 mp3 文件我正在使用 jsonparser 来获取 mp3 文件的响应并保存在 photolibrary 中?

4

1 回答 1

1
NSURL *url = [NSURL URLWithString:@"http://www.pacdv.com/sounds/people_sound_effects/c-c-2.mp3"]; 
NSData *soundData = [NSData dataWithContentsOfURL:url];
NSString *documents = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
NSString *filePath = [documents stringByAppendingPathComponent:@"sound.caf"];
[soundData writeToFile:filePath atomically:YES];
于 2013-01-21T15:17:11.320 回答