开发者

Write NSData to a file?

开发者 https://www.devze.com 2023-01-13 06:33 出处:网络
I am trying to write an nsdata to a file on my disk, I have the following code and it doesn\'t work, am i doing anything wrong?

I am trying to write an nsdata to a file on my disk, I have the following code and it doesn't work, am i doing anything wrong?

Boolean result = [data writeToFile:@"/Users/ar开发者_如何转开发yaxt/Desktop/test2.avi" atomically:YES];

test2.avi doesn't exist, I am assuming that writeToFile would create it for me


Try using :

NSError *error = nil;
path=@"/Users/aryaxt/Desktop/test2.avi";
[data writeToFile:path options:NSDataWritingAtomic error:&error];
NSLog(@"Write returned error: %@", [error localizedDescription]);

That'll tell you why the write is failing.

0

精彩评论

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