• 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 [SORTED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Getting A Key Value From An NSDictionary [SORTED]


  • Subject: RE: Getting A Key Value From An NSDictionary [SORTED]
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Mon, 08 Dec 2003 14:30:46 +0000

Hi Guys,

I've seen my error and have sorted this now.
I needed to obtain the key "item" first by using objectForKey which is an EO and then use keyValueForKey on the required property of the "item" to then be able to do what I needed.


Jonathan :^)


From: "Jonathan Fleming" <email@hidden>
To: email@hidden
Subject: Getting A Key Value From An NSDictionary
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.

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

  • Follow-Ups:
    • RE: Getting A Key Value From An NSDictionary [SORTED]
      • From: Ben Trumbull <email@hidden>
  • Prev by Date: Re: web board recursive component
  • Next by Date: Setting EOEditingContext's Undo Manager to null
  • Previous by thread: Split Client and Server Code
  • Next by thread: RE: Getting A Key Value From An NSDictionary [SORTED]
  • Index(es):
    • Date
    • Thread