开发者

NSComboBox data sources and reloadData

开发者 https://www.devze.com 2023-03-29 04:36 出处:网络
I have an NSCombobox in my app and I have a datasource set up for it. IBOutlet NSComboBox *comboBox; I also specify at some point in my program:

I have an NSCombobox in my app and I have a datasource set up for it.

 IBOutlet NSComboBox *comboBox;

I also specify at some point in my program:

[comboBox reloadData];

My thought would be that after this call, I should get calls to these methods as long as I remembered to set the datasource of 开发者_JS百科the combo box (which i did):

- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index
- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox

But I don't. Is this not how combo boxes work?


If you're using a combo box with a data source, and provided you can set up whatever structures the data source methods require before the combo first draws, you only need to call reloadData if the data subsequently changes.

If the data source methods aren't being called at all – either before or after a call to reloadData – make sure the combo box is configured to use a data source. In the nib, under Combo Box, select Uses Data Source, or call [comboBox setUsesDataSource:YES] in code.

0

精彩评论

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