Re: NSDictionary Within An NSDictionary - Getting Values
Re: NSDictionary Within An NSDictionary - Getting Values
- Subject: Re: NSDictionary Within An NSDictionary - Getting Values
- From: "Jonathan Fleming" <email@hidden>
- Date: Wed, 21 Jan 2004 01:48:29 +0000
From: Jonathan Rochkind <email@hidden>
To: "Jonathan Fleming" <email@hidden>,
email@hidden
Subject: Re: NSDictionary Within An NSDictionary - Getting Values
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");
Yeah, somehow... well it happened, I kept on writting an incorrect key name
and I could not get the value. I knew the mechanism I was using should work
(KVC) because I had done it so many times before but I think I paniced
because my brain was telling me that as I was taking on the complication of
writing an e-commerce app it should be harder than it was.
It was only after I read the breakdown that Chuck posted that it became
blatently obvious I was doing something wrong, and I was... writting the key
name incorrectly.
At the end of the day the mechanics of WebObjects is the mechanism and if
you know the mechanism there's no real technical need for you to know the
machanics... I think I was falling into the idea that I should somehow be
delving more into the machanics and this only increased the confusion in my
mind making things seem more complicated that they really are.
WebObjects, is WebObjects, is WebObjects in whatever mask it appears to
wear... how many ways is there to skin a cat... know-'hat-I-mean?
Regards
Jonathan F :^)
--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.
_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo
_______________________________________________
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.