• 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: Getting A Key Value From An NSDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting A Key Value From An NSDictionary


  • Subject: Re: Getting A Key Value From An NSDictionary
  • From: Ricardo Strausz <email@hidden>
  • Date: Mon, 8 Dec 2003 13:47:46 -0600

did you try valueForKey()??

On Dec 8, 2003, at 3:09, Jonathan Fleming wrote:

'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.

References: 
 >Getting A Key Value From An NSDictionary (From: "Jonathan Fleming" <email@hidden>)

  • Prev by Date: Re: "Cannot obtain globalId for an object which..."
  • Next by Date: How to get an WOD value within the component constructor
  • Previous by thread: Getting A Key Value From An NSDictionary
  • Next by thread: Split Client and Server Code
  • Index(es):
    • Date
    • Thread