FROM : Johnny Lundy
DATE : Sun Apr 20 15:27:57 2008
As follow-up, I set the bindings of the popup to be
content: Array Controller.arrangedObjects
content objects: not used
content values: Array Controller.arrangedObjects.name
When I pass the selection of the Array Controller to my method, all I
get for the parameter in NSLog is
victim: <_NSControllerObjectProxy: 0x1059790> for the first parameter
that was passed to the method.
and trying to log [victim selection] or [victim selectionIndex], since
it claims that it is an arrayController proxy, of course returns
Unrecognized Selector.
I just want to get either the index or the value of the array that my
popupButton/NSArrayController combo has when the user selects an item
from the popup. Anything that will just tell me which of the seven
items the user chose from the popup (without using IBAction).
What's the secret? If I could get an integer that is the array index,
or the content of that selected array member, that's all that I need.
The array is a mutable array of seven mutable dictionaries, and the
same technique works fine for passing the selected item (i.e. the row)
of a one-column tableView.
I might have to put a textfield or something on the UI to be able to
see what the controller has in it - <_NSControllerObjectProxy:
0x1059790> doesn't help me.
> Thanks Steve,
>
> I have the IBAction working no problem. What I was looking to do is
> to use bindings, as I am trying to learn about them - I am doing
> this project to teach myself about MVC-compliant techniques. I have
> the array controller and just need to know which one of the popup's
> bindings to use (it has six of them). I can use either the selection
> index or the actual model array value (an NSMutableDictionary) to
> work with - the thing is
>
> I found an example here http://www.cocoabuilder.com/archive/message/cocoa/2006/5/31/164724
> which Matt Neuburg suggests to use 3 bindings.
>
> And a sample project here, an attached file to post #7 halfway down
> the page:
>
> http://forums.macrumors.com/showthread.php?t=420530
>
> Saying the same thing.
>
> So I am going to experiment with those.
>
> Johnny
> Good evening,
>
> I am having trouble understanding the bindings for NSPopupButton.
>
> View: NSPopupButton
> Controller: NSArrayController, just for the popup button
> Model: NSMutableArray of NSMutableDictionaries.
>
>
> I have the array controller bound to the array in the model, and that
> is working fine.
>
> My question is: which one of these multiple bindings do I want if I
> want to have either the popup button's selectedIndex or the actual
> mutableDictionary at that index passed to my method (I am using
> another NSButton to invoke the method using the selection of the array
> controller as an argument).
>
> So far I am getting the proper strings in the popup, but what is
> getting passed to the method looks like the [dictionary description]
> of the first item in the model array, no matter what I select in the
> popupButton.
>
> I've spent the whole day scouring the docs for some guidance in which
> of the (Content, Content Objects, Content Values, Selected Index,
> Selected Object, and Selected Value) to use in order to send the model
> array element (or its index, I can deal with either) as an argument to
> my method.
>
> Thanks in advance if anyone can point me to a more descriptive doc
> than Apple's laconic one on these six different attributes of
> selection for popupbuttons.
>
DATE : Sun Apr 20 15:27:57 2008
As follow-up, I set the bindings of the popup to be
content: Array Controller.arrangedObjects
content objects: not used
content values: Array Controller.arrangedObjects.name
When I pass the selection of the Array Controller to my method, all I
get for the parameter in NSLog is
victim: <_NSControllerObjectProxy: 0x1059790> for the first parameter
that was passed to the method.
and trying to log [victim selection] or [victim selectionIndex], since
it claims that it is an arrayController proxy, of course returns
Unrecognized Selector.
I just want to get either the index or the value of the array that my
popupButton/NSArrayController combo has when the user selects an item
from the popup. Anything that will just tell me which of the seven
items the user chose from the popup (without using IBAction).
What's the secret? If I could get an integer that is the array index,
or the content of that selected array member, that's all that I need.
The array is a mutable array of seven mutable dictionaries, and the
same technique works fine for passing the selected item (i.e. the row)
of a one-column tableView.
I might have to put a textfield or something on the UI to be able to
see what the controller has in it - <_NSControllerObjectProxy:
0x1059790> doesn't help me.
> Thanks Steve,
>
> I have the IBAction working no problem. What I was looking to do is
> to use bindings, as I am trying to learn about them - I am doing
> this project to teach myself about MVC-compliant techniques. I have
> the array controller and just need to know which one of the popup's
> bindings to use (it has six of them). I can use either the selection
> index or the actual model array value (an NSMutableDictionary) to
> work with - the thing is
>
> I found an example here http://www.cocoabuilder.com/archive/message/cocoa/2006/5/31/164724
> which Matt Neuburg suggests to use 3 bindings.
>
> And a sample project here, an attached file to post #7 halfway down
> the page:
>
> http://forums.macrumors.com/showthread.php?t=420530
>
> Saying the same thing.
>
> So I am going to experiment with those.
>
> Johnny
> Good evening,
>
> I am having trouble understanding the bindings for NSPopupButton.
>
> View: NSPopupButton
> Controller: NSArrayController, just for the popup button
> Model: NSMutableArray of NSMutableDictionaries.
>
>
> I have the array controller bound to the array in the model, and that
> is working fine.
>
> My question is: which one of these multiple bindings do I want if I
> want to have either the popup button's selectedIndex or the actual
> mutableDictionary at that index passed to my method (I am using
> another NSButton to invoke the method using the selection of the array
> controller as an argument).
>
> So far I am getting the proper strings in the popup, but what is
> getting passed to the method looks like the [dictionary description]
> of the first item in the model array, no matter what I select in the
> popupButton.
>
> I've spent the whole day scouring the docs for some guidance in which
> of the (Content, Content Objects, Content Values, Selected Index,
> Selected Object, and Selected Value) to use in order to send the model
> array element (or its index, I can deal with either) as an argument to
> my method.
>
> Thanks in advance if anyone can point me to a more descriptive doc
> than Apple's laconic one on these six different attributes of
> selection for popupbuttons.
>
| Related mails | Author | Date |
|---|---|---|
| Johnny Lundy | Apr 20, 02:58 | |
| Steve Weller | Apr 20, 06:49 | |
| Johnny Lundy | Apr 20, 15:06 | |
| Johnny Lundy | Apr 20, 15:27 | |
| Keary Suska | Apr 20, 16:30 |






Cocoa mail archive

