NSComboBox and Datasource issue
NSComboBox and Datasource issue
- Subject: NSComboBox and Datasource issue
- From: Scott Little <email@hidden>
- Date: Tue, 17 Feb 2004 18:48:18 +0100
Hello,
I have a couple of queries that I believe are based around the same issue. I
have been working through the Vermont recipes book and also playing around
with the bindings features in XCode and have come across difficulties in both
of these and am wondering what I am forgetting (despite trying to follow
clearly written instructions :-p)
The situation involves the ComboBox/Datasource from Vermont Recipes and the
Binding example in the Currency Converter in the Apple docs.
Here is a quick, yet detailed description of the ComboBox issue (I did a
search in the archives and found similar issues but nothing describing exactly
the same thing).
Created the ComboBox, connected its two outlets (datasource and delegate) to
my document controller class (and set its flag to use datasource). I added the
four methods from the NSComboBoxDataSource protocol, with log statements in
each.
When I run the program I get the combobox with the correct default value of
"All", however, when I click on the little arrow the list has empty values. As
someone else noticed, I can type in values and it does the search and
autocompletes for me, so my data source is properly connected (also see this
in the logs)
However, what I found is that, the method (numberOfItemsInComboBox:) is called
before the combobox object is properly associated with my outlet in the
controller class. I know this because I have seen that my [self comboBoxView]
returns nil and the comboBox passed in has the same address as the [self
comboBoxView] after the window is created.
Thus my method returns 0 for the number of items and Cocoa seems to respect
this and not draw any items in the drop down. Problem is that this method is
NEVER called again and I can't see why not. Doesn't it need to update this
from time to time? If not shouldn't it be called after the created ComboBox is
connected to its outlet (the comboBox is created in my nib BTW, not
programatically).
Now you are probably wondering what the h#%$ that has to do with bindings!
Well when I did the currency converter example, I created my three text fields
and linked them using the bindings and an NSObjectController based on a simple
class that does the calculation for the conversion. However, I noticed that it
would properly call my accessors for the "Euros to Convert" and the "Exchange
Rate" but the "Converted Other Amount" only got called once when the window is
first displayed, never again.
The docs for the Currency converted indicated that it would know (based on the
bindings setup as indicated within) that this value will be changed and call
the proper accessor to get the value, but it doesn't.
Basically it seems that either something doesn't work right for this
synchronization (not likely since both are examples that seem well
established) or I am completely missing something somewhere.
Can anyway shed any light on this(these) long-winded question(s)?
Thanks,
Scott Little
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.