objective c - How to check for End-of-File using NSFileHandle's readabilityHandler? -


i reading data nsfilehandle (from nspipe) using readabilityhandler block:

filehandle.readabilityhandler = ^( nsfilehandle *handle ) {      [self processdata: [handle availabledata]]; } 

this works fine, data expect fed processdata method. problem need know when last chunk of data read. availabledata should return empty nsdata instance if reached end-of-file, problem reachability handler not called again on eof.

i can’t find how kind of notification or callback on eof. missing? apple providing asynchronous reading api without eof callback?

by way, cannot use runloop based readinbackgroundandnotify method since don’t have runloop available. if cannot work nsfilehandle api directly use dispatch source io.

i'm afraid you're out of luck doing nsfilehandle if can't use readinbackgroundandnotify.

two solutions see:

  1. create runloop , use readinbackgroundandnotify.
  2. roll own implementation using dispatch_io_*

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -