In an encryption tool I am nearly finished with, I can’t seem to write the encrypted data to a file.
Here is what I have:
NSData *encryptedData = [data AES256EncryptWithKey:key];
[encryptedData writeToFile:@"~/Desktop/file.txt" atomically:YES];
If ‘file.txt’ is not found, it should create it.
Thank You
First,
-writeToFile:atomically:is the name of the method you are trying to use– not, as you have written,-writeToFile:automatically:. And second, this method should usually be avoided in favor of one that takes an out NSError parameter.Try
-writeToFile:options:error:if you’d like to be able to log a useful diagnostic when something goes wrong.