O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Non-blocking reads

If a process takes a long time to return output, you don’t want your application to stop while waiting for output from the program. To avoid this case, you create a file handle that does non-blocking reading. In particular, you set up the file handle so that it posts a notification when there is data to be processed.

In this section, you are going to create a task which runs traceroute. traceroute sends out packets to discover the routers between your machine and another host. The responses from the routers sometimes take a while to get back. You will read the data in the background and append it to the text view.

The notification created will be an NSFileHandleReadCompletionNotification. To start the file handle waiting for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required