开发者

NSTableView requesting Data too early

开发者 https://www.devze.com 2023-01-14 20:34 出处:网络
I\'ve run into a bit of开发者_StackOverflow中文版 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

I've run into a bit of开发者_StackOverflow中文版 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消