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

The NSTableViewDataSource Protocol

Setting up a data source for a table view follows the same pattern that you saw in Chapter 6 when setting up a delegate for the speech synthesizer. There are three steps: conforming to the protocol, implementing methods from the protocol, and setting the dataSource property.

Conforming to the protocol

In MainWindowController.swift, add the NSTableViewDataSource protocol to the MainWindowController class definition.

i​m​p​o​r​t​ ​C​o​c​o​a​

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​,​ ​N​S​S​p​e​e​c​h​S​y​n​t​h​e​s​i​z​e​r​D​e​l​e​g​a​t​e​,​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​N​S​W​i​n​d​o​w​D​e​l​e​g​a​t​e​ ​{c​l​a​s​s​ ...

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