Opening URLs

The data for each course contains the URL of a web page that has a description of that class. The last functionality for this app is to open that web page in the user’s browser if the user double-clicks on the course.

To get the table view to respond to a double-click you must set the doubleAction and target of the table view. Unlike most target/action pairs, doubleAction must be set programmatically. Open MainWindowController.swift and add an outlet to the table view and the array controller:

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

 ​ ​ ​ ​@​I​B​O​u​t​l​e​t​ ​v​a​r​ ​t​a​b​l​e​V​i​e​w​:​ ​N​S​T​a​b​l​e​V​i​e​w​!​
 ​ ​ ​ ​@​I​B​O​u​t​l​e​t​ ​v​a​r​ ​a​r​r​a​y​C​o​n​t​r​o​l​l​e​r​:​ ...

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.