> On Jun 29, 2016, at 8:40 PM, Graham Cox <graham....@bigpond.com 
> <mailto:graham....@bigpond.com>> wrote:
> 
> Reading the documentation, NSFileHandle seems to have only one file offset, 
> which is common to both read and write, which is a bit puzzling, because 
> surely you’d want to write at the end of the file, but read from wherever 
> you’d read from last time.

NSFileHandle is just exposing the semantics of a file stream, i.e. a standard C 
`FILE*`, or a Unix file-descriptor. Every file I/O API I can think of, on any 
platform, has this behavior — there is a single offset that’s used for reads 
and writes. It may not make sense to you, but it’s been that way since at least 
1969 :)

So yeah, you’ll need two handles, one to write and one to read. But I have 
doubts that the readabilityHandler is going to work —  I don’t know if it will 
actually detect that the EOF on the file has advanced. This kind of handler is 
intended for non-seekable streams like sockets or pipes.

If I were going to implement a custom logging console, I’d write to a “.log” 
file and have Console.app open the file, since it’s quite good at displaying 
logs and updating them in real time.

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to