Getting A Key Value From An NSDictionary
Getting A Key Value From An NSDictionary
- Subject: Getting A Key Value From An NSDictionary
- From: "Jonathan Fleming" <email@hidden>
- Date: Mon, 08 Dec 2003 09:09:34 +0000
'ello dev heads
I'm looking for your help once again...
I want to get the "listPrice" value out of this NSDictionary but it keeps
giving me a null value
Here's the content of the dictionary and the statements I'm using in the
method below:
Cart Content:
{item = {values = {attr1 = "Male Adult"; 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 = "K9-BD-01";
listPrice = 18.000000000000000000000000000000; supplier =
"<com.webobjects.eocontrol.EOGenericRecord 8e2dd
(com.webobjects.eoaccess.EOAccessFaultHandler
_EOIntegralKeyGlobalID[Supplier (java.lang.Integer)1])>"; itemid = "EST-6";
product = "<com.webobjectsexamples.petstore.Product 34e29b
_EOVectorKeyGlobalID[Product (java.lang.String)K9-BD-01]>"; unitCost =
12.000000000000000000000000000000; status = "P"; inventory =
"<com.webobjectsexamples.petstore.Inventory 203c31
_EOVectorKeyGlobalID[Inventory (java.lang.String)EST-6]>"; }; this =
"<com.webobjectsexamples.petstore.Item 1ca803 _EOVectorKeyGlobalID[Item
(java.lang.String)EST-6]>"; }; total = 36.0; qty = 2; }
I tried using the key like this and was returned ===== item.listPrice:
null
Using key as I think it should have been, I was returned ===== listPrice:
null
These are the statements that I've tried to get the value with ===
public NSMutableDictionary cartTotalOnUpdate() {
for(int i=0;i<cartItems.count();i++){
//ctou==cartTotalOnUpdate
NSMutableDictionary
ctou=(NSMutableDictionary)cartItems.objectAtIndex(i);
Object item1 = ctou.objectForKey("listPrice");
Item item2 = (Item)ctou.objectForKey("listPrice");
NSLog.out.appendln("===\r listPrice:\r " + item1);
NSLog.out.appendln("===\r listPrice:\r " + item2);
}
}
The thing is I also use these statements (below) in the method above to get
the "total" and "qty" values without a problem, so where am I going wrong:
BigDecimal iQty = (BigDecimal)ctou.objectForKey("qty");
Double iTotal = (Double)ctou.objectForKey("total");
TIA
Jonathan :^)
_________________________________________________________________
Tired of 56k? Get a FREE BT Broadband connection
http://www.msn.co.uk/specials/btbroadband
_______________________________________________
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.