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.

class ViewController: NSViewController {

    @IBOutlet var outputView: NSTextView!
    @IBOutlet weak var hostField: NSTextField!

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.