Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write NSData to a file?

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/aryaxt/Desktop/test2.avi" atomically:YES];

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

like image 225
aryaxt Avatar asked Aug 28 '10 21:08

aryaxt


1 Answers

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.

like image 71
John Franklin Avatar answered Oct 28 '22 16:10

John Franklin