iPing

Now you are going to write a Cocoa app that uses NSTask to run ping (Figure 35.5).

Figure 35.5  Completed application

Completed application

In Xcode, create a new project, iPing, of type Cocoa Application. Uncheck Create Document-Based Application. You will want a storyboard for this app, so ensure that Use Storyboards is checked.

Open ViewController.swift. First, remove all of the methods from ViewController that were added as part of the Xcode template. Then add several properties and a stub for an action method.

c​l​a​s​s​ ​V​i​e​w​C​o​n​t​r​o​l​l​e​r​:​ ​N​S​V​i​e​w​C​o​n​t​r​o​l​l​e​r​ ​{​

 ​ ​ ​ ​@​I​B​O​u​t​l​e​t​ ​v​a​r​ ​o​u​t​p​u​t​V​i​e​w​:​ ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.