iOS Development Tips--two ways to write files while accepting data edges

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.