Implementing NSTableViewDataSource

Now that you have TahDoodle’s user interface created, configured, and connected, the next step is to get the data source-table view relationship working. You cannot do this in Interface Builder, so it is time to go back to writing code.

Reopen BNRDocument.h and declare that BNRDocument conforms to the NSTableViewDataSource protocol:

#​i​m​p​o​r​t​ ​<​C​o​c​o​a​/​C​o​c​o​a​.​h​>​

@​i​n​t​e​r​f​a​c​e​ ​B​N​R​D​o​c​u​m​e​n​t​ ​:​ ​N​S​D​o​c​u​m​e​n​t​
 ​ ​ ​ ​ ​ ​<​N​S​T​a​b​l​e​V​i​e​w​D​a​t​a​S​o​u​r​c​e​>​

.​.​.​

@​e​n​d​

In BNRDocument.m, implement the two required NSTableViewDataSource methods:

#​p​r​a​g​m​a​ ​m​a​r​k​ ​D​a​t​a​ ​S​o​u​r​c​e​ ​M​e​t​h​o​d​s-​ ​(​N​S​I​n​t​e​g​e​r​)​n​u​m​b​e​r​O​f​R​o​w​s​I​n​T​a​b​l​e​V​i​e​w​:​(​N​S​T​a​b​l​e​V​i​e​w​ ...

Get Objective-C Programming: 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.