0
votes

I have a MyViewController class which inherits from a MyGeneralViewController (itself a NSViewController subclass). In MyViewController xib file, I added two NSComboBox, and selected "use datasource" in IB and connected the datasource and delegate outlets for both. (they all refer to the same object for that)

Then I implemented the numberOfItemsInComboBox: and comboBox:objectValueForItemAtIndex: in my class. When I run the application, I got two identical console messages (one for each combo I presume): "Illegal NSComboBox data source (<MyViewController: 0x6300001404d0>). Must implement numberOfItemsInComboBox: and comboBox:objectValueForItemAtIndex:"

After many essays, I decided to remove these combos from IB and create/manage them programmatically (setting the useDatasource flag to TRUE, datasource etc). Still the same message in console. I noticed in this situation that although my combos are alive, after setting their datasource and delegate to self (with appropriate delegations) the combo.datasource and combo.delegate return nil.

Then, I created a special NS Object subclass designed only to serve at the datasource for these combos: same message.

In a desperate try, I removed this MyDataSource class and transferred the NSComboDataSource and NSComboDelegate stuff to MyViewController superclass. You know what? "Illegal NSComboBox data source (<MyGeneralViewController: 0x6200001404a2>). Must implement numberOfItemsInComboBox: and comboBox:objectValueForItemAtIndex:"

For all this tries, I tested both IB and programmatically approach. But always got the same warning (and empty NSComboBox content). I run Xcode 9.2 under Sierra, for a 10.11 target (also tried for 10.12 with no success) - Any idea?

1

1 Answers

0
votes

After recreating a new project from scratch and copy paste the former code, everything works normally... with the MyViewController class or its MyGeneralViewController class, and datasource/delegation set in IB. Seems like a bug somewhere in XCode or a corrupted project fileā€¦