First, Nsfilehanle
- Use note: When writing data to a file, you must create an empty file
- Specify how the file is written-overwrite or append
- Finally remember to close
The <1> code is intercepted in the practice of large file transfer. Create an empty file before writing the data, initialize the Nsfilehandle class
<2> set how the file is written (without writing, overwriting the write data by default) and writing the received data to an empty file
<3> Finally, be sure to close the object of the action file
Second, Nsoutputstream
- Use Note: Use this class to manipulate files without creating an empty file in advance, but remember to open the stream or the file will not be written successfully
- The way the file is written when it is initialized
- In the process of writing the data, the operation is a byte array, so the data is converted to a byte array
- Finally, remember to close the stream
<1> initialize the object while setting the file write mode, you must remember to open the stream
<2> Writing data
<3> Close Stream
iOS Development Tips--two ways to write files while accepting data edges