How can I write a string to a binary file? I have tried a lot, but every time my file appear as a plain text file..
I am not interested in a plist file..
string = String(data: data, encoding: String.Encoding.utf8)!;
var buffer = [UInt8](string.utf8);
var f = fopen("newdata.dat", "w");
let success = fwrite(buffer, MemoryLayout<UInt8>.size, buffer.count, f);
fsync(fileno(f));
fclose(f);
print("success: \(success)");