views:

37

answers:

2

Hi.

I've run into a bit of an issue with NSTableView. The problem is that the table view is requesting data too early (it immediately requests the data from the controller), as in, the data is not there when the table view asks for it. Other methods, which gather the data to be shown in the table view haven't finished executing by the time NSTableView requests the data.

Hope that makes some kind of sense! I'm using Objective-C and doing mac dev (not iphone) btw.

Anyway, is there any way around this?

Thanks in advance.

+2  A: 

Sounds like you're populating the table view asynchronously? If so you could call reloadData or reloadDataForRowIndexes:columnIndexes: on your table view in the method that handles the response to refresh the table view once the data has loaded.

Simon Whitaker
+4  A: 

The NSTableView is asking for the data likely because you have told it that there are say 20 rows of data. Once it knows there are 20 rows, it will start asking for it.

If you are using the NSTableView data source Delegate, its easy, just return 0 for the number of rows until everything is ready - then return the number of rows that there are.

IE you need these calls in the delegate:

– numberOfRowsInTableView:
– tableView:objectValueForTableColumn:row:

If you are not using the NSTableViewDataSource, and have wired up the controller in Interface Builder, then you will have to somehow only give the controller the data when its all ready.

Tom Andersen
thanks! that appears to have worked :)
James Eggers