I'm logging data to a file that I keep open with NSFileHandle. These log files can be emailed out, is it necessary to close NSFileHandle before I send the email
Asked
Active
Viewed 1,014 times
1 Answers
4
You don't need to close the file handle but if you want everything that has been written so far, you should call synchronizeFile
on the file handle to ensure anything in memory has been written to the file.

rmaddy
- 314,917
- 42
- 532
- 579
-
yes i'm doing a `synchronizeFile` but is there any documentation or reasoning you can point me as to why a concurrent write and read wouldn't cause a crash – pflous Mar 17 '16 at 15:44
-
1How are you reading the file? There should be no problem copying the file even if another thread might write to the file. The OS will have no problem supporting that. – rmaddy Mar 17 '16 at 18:06
-
Using MFMailComposeViewController and doing `addAttachmentData:`, I imagine there is a read happening somewhere upon sending – pflous Mar 17 '16 at 20:19