Shehzan
Shehzan

Reputation: 287

How can NSString write to a file when I have a FILE handle open for reading?

I have a sample iOS app in which I am trying to measure the time taken by the various file writing alternatives. While measuring the time, I noticed that NSString's writeToFile method write to the file even when I have a file handle for read on the same file that has been obtained by using fopen().

Upvotes: 0

Views: 70

Answers (1)

gnasher729
gnasher729

Reputation: 52632

Well, that's easy. writeToFile creates a new file with the same name. Your file handle refers to the old file. The old file will disappear when you close the file handle; it's name already disappeared when writeToFile created a new file.

Upvotes: 1

Related Questions