> On 1 Jul 2016, at 2:18 AM, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 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.

Fair enough, though probably one to write is sufficient in this case - I can 
pass the text also directly to my text view, so it has the same content, it 
just then disallows something else to write to the same file and have it show 
up in the text view, but that is a theoretical benefit anyway - I don’t have a 
use-case for it right now.

What still seems a bit unclear is what a file handle “for update” is meant for, 
if separate read and write handles are needed.

> 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.

OK, understood.

> 
> 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.
> 

Well, it’s not really a full technical log file - it’s just something that 
allows a user to see the history of a very small set of particular events 
(think “activity” rather than a true log). These are not the sorts of users who 
are going to like being forced to use Console.app

—Graham



_______________________________________________

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