Reputation: 5423
I'm finding the way to read/write file with locking. Does iOS sdk support this feature?
I see there are 2 ways to read-write file.
First with NSFileManager
and another is NSInputStream
/NSOutputStream
, but I haven't seen the way to handle file concurrency, for example, open file with write lock.
Or I have to implement those locking by myself?
Upvotes: 1
Views: 2949
Reputation: 9768
In general, iOS apps don't bother locking files because the documents are sandboxed away from other applications. flock() is implemented in iOS, but I haven't personally used it. It might be useful if you have multiple threads or classes sharing the same files.
Upvotes: 3
Reputation: 31589
NSOutputStream outputStreamToFileAtPath:append:
keeps a write lock to the file.
You can still use fopen
and fstream
(in objc++) and they will work just like in a regular linux.
Upvotes: 1