Inserting a string at a specified line in text file using objective c

前端 未结 1 1997
梦毁少年i
梦毁少年i 2020-12-21 16:21

Lets say I have a text file with the following data

Username

User ID

Details

suppose, I want to insert a

1条回答
  •  时光取名叫无心
    2020-12-21 16:46

    The only way to do this is to read the file into memory, modify the internal representation of the data, and write it back out.

    There are some variations on this process, but in short; files are not like real paper and ink documents: You can't insert content into the middle of a file, only replace what is already there.

    Edit: To clarify, you can only grow a file at the end; not in the middle.

    0 讨论(0)
提交回复
热议问题