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

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

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