开发者

NSFileHandle weird problem with iphone

开发者 https://www.devze.com 2022-12-18 22:07 出处:网络
i am downloading an mp3 file using NSURLConnection and saving it to a file . The problem is mp3 file is created (found the mp3 file created when using simulator), but i cannot access the mp3 file . An

i am downloading an mp3 file using NSURLConnection and saving it to a file . The problem is mp3 file is created (found the mp3 file created when using simulator), but i cannot access the mp3 file . Any ideas?!!!!!

This is the code i'm using

filename = [[NSSearc开发者_StackOverflow社区hPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:save_name]; 
[[NSFileManager defaultManager] createFileAtPath:filename contents:nil attributes:nil]; 

file = [[NSFileHandle fileHandleForUpdatingAtPath:filename] retain];// file is in .h

if (file) {
   [file seekToEndOfFile];
} 
[file writeData:data]; 


Looks like you need to close the file after writing to it.

[fileHandle closeFile];
0

精彩评论

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