• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDictionary and WOPopup Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDictionary and WOPopup Question


  • Subject: Re: NSDictionary and WOPopup Question
  • From: Chuck Hill <email@hidden>
  • Date: Wed, 27 Oct 2004 12:03:52 -0700

Pretty much what PWOPopup does, but it takes a separate list of the key so
that they can be ordered.  There is no concept of ordering for the keys in
a dictionary.  Sometimes that matters, sometimes it does not.

Chuck

At 06:58 PM 27/10/2004 +0000, Hugi Thordarson wrote:
>Ok, I think I get this. At the very least, I'm going to make an
>attempt. I'm going to write this out in code, since I'm afraid of
>confusing you to the point of desperation if I attempt regular English
>:-).
>
>Working from the following assumptions:
>* You have an NSDictionary called "divisions".
>* It contains the names of divisions as keys, and their ID-numbers as
>values (Integers).
>* No two divisions have the same name
>* You want to display the division names in a pop-up menu.
>* The value you need is the Integer value
>* You're setting an attribute called "divisionNumber" in an EO instance
>called someEO
>
>Of course, the best thing to do is to take all of this and put it in a
>separate component.
>(Disclaimer: I did not check to see if this code compiles and thus it
>might contain errors.)
>
>/**
>  * Your divisions and their numbers
>  */
>public NSDictionary divisions() {
>	NSMutableDictionary d = new NSMutableDictionary();
>
>	d.setObjectForKey( new Integer( 1 ), "Sales" );
>	d.setObjectForKey( new Integer( 2 ), "Human resources" );
>	d.setObjectForKey( new Integer( 3 ), "Alien resources" );
>
>	return d;
>}
>
>/**
>  * The names of your divisions.
>  * Bind this to your WOPopUpButton's "list" attribute
>  */
>public NSArray divisionNames() {
>	return divisions().allKeys();
>}
>
>/**
>  * Gets the correct display string from your dictionary for the WOPopUp
>  * Bind selectedDivisionName to your WOPopUpButton's
>"selection"-attribute.
>  */
>public String selectedDivisionName() {
>	Enumeration e = divisions().objectEnumerator();
>
>	while( e.hasMoreElements() ) {
>		Object o = e.nextElement();
>
>		if( o.equals( someEO.divisionNumber() ) )
>			return (String)divisions().allKeysForObject( s ).lastObject();
>	}
>
>	return null;
>}
>
>/**
>  * Sets the selected division name.
>  */
>public void setSelectedDivisionName( String newDivisionName ) {
>	someEO.setDivisionNumber( (String)divisions().valueForKey(
>newDivisionName ) );
>}
>
>
>/**
>  * Ends my letter ;-)
>  */
>public String greetings() {
>	return "Cheers,\nHugi";
>}
>
>// Hugi Thordarson
>// Development mgr.
>// Vefsyn hf. - development, analysis, marketing
>// http://www.vefsyn.com/
>
>
>
>
>
>On 27.10.2004, at 17:51, James Cicenia wrote:
>
>> OK - lol -
>>
>> Say I have a dictionary of Integers with a string key for display.
>> I bind allKeys to the list. However how will I get the string when
>> the object gives a Integer back? Well I thought then let me
>> create a reverse dictionary with strings as the values and the
>> Integers as the key. Then in my selection methods I can one
>> dictionary to get the string and the other to set back the Integer.
>>
>> Does any of this make sense?
>>
>> - James
>>
>>
>>
>> On Oct 27, 2004, at 12:13 PM, Chuck Hill wrote:
>>
>>> I, for one, can't understand what you mean.  Can you say that again?
>>> :-)
>>>
>>> Chuck
>>>
>>> On Oct 27, 2004, at 7:18 AM, James Cicenia wrote:
>>>
>>>> Hello -
>>>>
>>>> I want to do a repeating list with a popup. I thought that
>>>> NSDictionary would be good, especially now that I look to use KVC
>>>> for everything. Anyway, my first popup with NSDictionary had me
>>>> making two NSDictionaries with the key/values just reversed. This
>>>> way I can get and set the popup using the two dictionaries in
>>>> reverse.
>>>>
>>>> Is this the way you pros do it?
>>>>
>>>> - James Cicenia
>
> _______________________________________________
>Do not post admin requests to the list. They will be ignored.
>Webobjects-dev mailing list      (email@hidden)
>Help/Unsubscribe/Update your Subscription:
e.net
>
>This email sent to email@hidden
>

--

Chuck Hill                                 email@hidden
Global Village Consulting Inc.             http://www.global-village.net
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: NSDictionary and WOPopup Question (From: James Cicenia <email@hidden>)
 >NSDictionary and WOPopup Question (From: James Cicenia <email@hidden>)
 >Re: NSDictionary and WOPopup Question (From: Chuck Hill <email@hidden>)
 >Re: NSDictionary and WOPopup Question (From: Hugi Thordarson <email@hidden>)

  • Prev by Date: Re: NSDictionary and WOPopup Question
  • Next by Date: Re: NSDictionary and WOPopup Question
  • Previous by thread: Re: NSDictionary and WOPopup Question
  • Next by thread: How to uninsert an EO from EC?
  • Index(es):
    • Date
    • Thread