O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

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

Asynchronous Reads

As mentioned in Chapter 23, the run loop is the object that waits for events, which may be keyboard, mouse, or timer events. These are all run loop data sources. You can also make a file handle a run loop data source.

In the next section, you are going to fork off a process that burps up data occasionally. You will attach a pipe to standardOutput, but instead of trying to read all the data from the file handle immediately, you will ask the file handle to read in the background and send a notification when data is ready.

You can use /sbin/ping to check whether you can make an IP connection to another machine. Try running it in Terminal:

$​ ​p​i​n​g​ ​-​c​1​0​ ​w​w​w​.​b​i​g​n​e​r​d​r​a​n​c​h​.​c​o​m​ P​I​N​G​ ...

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