[SOLVED] NSPopUpButton breaks in Snow Leopard
[SOLVED] NSPopUpButton breaks in Snow Leopard
- Subject: [SOLVED] NSPopUpButton breaks in Snow Leopard
- From: ALEXander <email@hidden>
- Date: Tue, 15 Sep 2009 16:06:50 +0200
Well, it seems that I forgot to post KVO notifications..... But it
worked in Leopard, I swear. It seems that in Leopard when a KVO
notification is posted for a popup button selection, the menu values
are reloaded as well automatically. This does not happen in SL
anymore. At least that's my theory. But that does not fit with the
fact that contentTypes actually does get called when it is supposed
to. Hmm...
Thanks,
ALEXander.
On 15.09.2009, at 08:28, ALEXander wrote:
Hi,
actually, I used the binding to the "Content" fields of
NSPopUpButton because the possible selection that has to be
displayed in the PopUp changes dynamically. Otherwise I could just
have set the menu in IB.
I put a breakpoint on controlTypes and it does return an NSArray
filled with NSCFStrings. But none of them are displayed in the menu.
The function is called everytime when it is supposed to be called,
i.e. everytime the menu changes. I never call that function myself.
The strange thing is, this worked beautifully under Leopard....
Any clues?
On 14.09.2009, at 23:33, Quincey Morris wrote:
On Sep 14, 2009, at 14:07, ALEXander wrote:
What do you mean by KVO compliant? I already have added a
setControlTypes function, this was not necessary in Leopard and also
does not fix the bug in Snow Leopard.
On Sep 13, 2009, at 15:11, ALEXander wrote:
1) in the File's Owner class I defined a function returning an
NSArray:
- (NSArray*) controlTypes
{
if ([[self selectedControls] count]) {
NSArray *returnArray = [NSArray arrayWithArray:[[[[self
selectedControls] objectAtIndex:0] configTypes] allKeys]];
return returnArray;
} else {
return nil;
}
}
The value returned by controlTypes looks like an array of
dictionary keys (configTypes allKeys), where the dictionary itself
comes from an array (selectedControls objectAtIndex:).
So the value returned by controlTypes *depends* on the values of
other objects, which may themselves depend on the contents of the
NIB being loaded.
But 'controlTypes' may be getting called before those other objects
are being loaded. If '[self selectedControls]' returns nil at the
time 'controlTypes' is called, for example, then 'controlTypes'
will return an empty array.
KVO compliance, in this case, means that if the value of 'self
selectedControls' or 'configTypes allKeys' changes later in the NIB
loading process, then 'controlTypes' needs to be called again by
the user interface, to get its new (correct) value.
In a case like this, you might be able to get compliance by making
'controlTypes' dependent on other keys (in Leopard, implement
+keyPathsForValuesAffectingControlTypes) or by manually calling
willChange/didChangeValueForKey: @"controlTypes" when the
underlying objects change.
Of course, if the value of 'controlTypes' is available before NIB
loading starts and never changes, this is all irrelevant and the
problem is somewhere else.
You could try setting a breakpoint in 'controlTypes' and see:
a. Is NIB loading in progress?
b. Does it maybe return an empty array the first time? Maybe it
only returns the correct array later, when it's too late.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden