small medium large xlarge

Generic-user-small
01 Feb 2009, 19:30
Markus Proske (3 posts)

First, let me thank you for the excellent book you are working on.

I have on minor issue on the Tables chapter. Following your guidance, I: - create project and controller - start Interfacebuilder, rename columns - new object, set to new controller class HelloAppTableViewController - dataSource and delegate outlets to the HelloAppTableViewController.

You write: Build & Go and you should get this error. Illegal NSTableView data source (<HelloAppTableViewController: 0x112870>). Must implement numberOfRowsInTableView: and tableView:objectValueForTableColumn:row:

Exactly that does not happen. Now if I take your example code, it looks like mine and HelloAppTable1 does not through that error either.

If I go on and add those two methods numberOfRowsInTableView: and tableView:objectValueForTableColumn:row: to my code, nothing happens. If I mistype “return” as “rturn”, no error is raised on compile either. If I take you HelloAppTable2, all works as expected.

So, my questions: is your HelloAppTable1 really correct? And what might I be missing?

Daniel_pragsmall
24 Feb 2009, 22:36
Daniel H Steinberg (98 posts)

Markus,

I’m sorry for taking so long to notice your question. Did you set the delegate and data source in Interface Builder? It sounds as if those are the connections you are missing.

Daniel

Generic-user-small
25 Feb 2009, 18:23
Markus Proske (3 posts)

Yes. It looks like your HelloAppTable1. At least I think so ;) As I can not attach files here, please look here: http://dl.getdropbox.com/u/56229/HelloApplicationTable.zip

Markus

Daniel_pragsmall
26 Feb 2009, 00:03
Daniel H Steinberg (98 posts)

Markus,

I just added these two methods to the HelloAppTableViewController and it worked fine.

  • (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView { return 5; }

  • (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { return @”hello”; }

The first call says there are 5 rows and the second call just fills all ten cells (two columns x 5 rows) with the word “hello”

Generic-user-small
03 May 2009, 11:45
Markus Proske (3 posts)

Daniel,

this time it was me to take long to respond. Yes, your lines work. Thanks.

I want to point you again to one part of my original question. If I remove those lines, NO error is thrown - in contrast to your book chapter 12.2: Illegal NSTableView data source (<HelloAppTableViewController: 0x112870>). Must implement numberOfRowsInTableView: and tableView:objectValueForTableColumn:row:

Markus

You must be logged in to comment