• 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 Within An NSDictionary - Getting Values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDictionary Within An NSDictionary - Getting Values


  • Subject: Re: NSDictionary Within An NSDictionary - Getting Values
  • From: Jonathan Rochkind <email@hidden>
  • Date: Tue, 20 Jan 2004 11:25:09 -0600

There's nothing special about a dictionary of dictionaries, and no special API on NSDictionary to allow you to treat it specially.

NSDictionary dictOfDicts; //assume exists

NSDictianary subDictionary = (NSDictionary) dictOfDicts.valueForKey("item");
Object value = subDictionary.valueForKey("itemPrice");

Or, in one line:

Object itemPrice = ((NSDictionary) dictOfDicts.valueForKey("item")).valueForKey("itemPrice");

--Jonathan


At 12:50 AM +0000 1/20/04, Jonathan Fleming wrote:
I want to be able to get the itemPrice value out of this dictionary so I'm using valueForKeyPath("item.itemPrice") and I've even used valueForKeyPath("item.values.itemPrice") but I just get the exception saying:
error1
com.webobjects.foundation.NSKeyValueCoding$UnknownKeyException: valueForKey(): lookup of unknown key: 'itemPrice'. This class does not have an instance variable of the name values or _values, nor a method of the name values, _values, getValues, or _getValues
error2
com.webobjects.foundation.NSKeyValueCoding$UnknownKeyException: valueForKey(): lookup of unknown key: 'values'. This class does not have an instance variable of the name values or _values, nor a method of the name values, _values, getValues, or _getValues



{item = {values = {attr1 = "Adult Male"; attr2 = <com.webobjects.foundation.NSKeyValueCoding$Null>; attr3 = <com.webobjects.foundation.NSKeyValueCoding$Null>; attr4 = <com.webobjects.foundation.NSKeyValueCoding$Null>; attr5 = <com.webobjects.foundation.NSKeyValueCoding$Null>; productid = "AV-SB-02"; listPrice = 15.000000000000000000000000000000; supplier = "<com.webobjects.eocontrol.EOGenericRecord 50988 (com.webobjects.eoaccess.EOAccessFaultHandler _EOIntegralKeyGlobalID[Supplier (java.lang.Integer)1])>"; itemid = "EST-19"; product = "<com.webobjectsexamples.petstore.Product 941f7 _EOVectorKeyGlobalID[Product (java.lang.String)AV-SB-02]>"; unitCost = 2.000000000000000000000000000000; status = "P"; inventory = "<com.webobjectsexamples.petstore.Inventory 34e29b _EOVectorKeyGlobalID[Inventory (java.lang.String)EST-19]>"; }; this = "<com.webobjectsexamples.petstore.Item 7a1576 _EOVectorKeyGlobalID[Item (java.lang.String)EST-19]>"; }; total = 30.0; qty = 3; }



Kind regards Jonathan

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >NSDictionary Within An NSDictionary - Getting Values (From: "Jonathan Fleming" <email@hidden>)

  • Prev by Date: WO Newsgroup
  • Next by Date: RE: Newbie question: adding EOModel to project
  • Previous by thread: Re: NSDictionary Within An NSDictionary - Getting Values
  • Next by thread: Re: NSDictionary Within An NSDictionary - Getting Values
  • Index(es):
    • Date
    • Thread