I am trying to write an NSData object to file, the code I am using is as follows.. The issue I am having is that it never creates the file..
// create file
NSFileManager *filemgr;
NSData *databuffer;
filemgr = [NSFileManager defaultManager];
databuffer = [filemgr contentsAtPath: @"/Users/imac/Desktop/mydata.dat" ];
// write to file
databuffer = [filemgr contentsAtPath: @"/Users/imac/Desktop/mydata.dat" ];
[filemgr createFileAtPath: @"/Users/imac/Desktop/mydata.dat" contents:receivedData attributes: nil];
any help would be greatly appreciated.
It turns out that you can (I just learned about it).
Here is a similar question. (the code you provided also should work).
Don’t forget to run it in simulator (not on iDevice) to get it to work.