Reputation: 4733
everyone!
Please help me to get the total value from given dictionary
{
"@averageBaseRate" = "296.7";
"@averageRate" = "296.7";
"@commissionableUsdTotal" = "1186.8";
"@currencyCode" = USD;
"@maxNightlyRate" = "296.7";
"@nightlyRateTotal" = "1186.8";
"@total" = "1186.8";
NightlyRatesPerRoom = {
"@size" = 1;
NightlyRate = {
....
How can I get the value from total key. Neither I can apply valueForKey nor I can apply objectForKey.
Any help is highly appreciated !
Upvotes: 0
Views: 88
Reputation: 1240
Nowerdays, you could even use
yourDict[@"yourkey"]
to get the value you stored for yourkey.
Upvotes: 0
Reputation: 17585
You can use this.
float total = [[yourDict objectForKey:@"@total"] floatValue];
Upvotes: 1
Reputation: 985
Hey Buddy always use like this ........
with this line you get all value of ABC Key In your Array
[array addObject:[dict objectForKey:@"ABC"]];
Upvotes: 0
Reputation: 19802
It looks strange that you have "@total" instead of "total" - looks like @ is a part of NSString. Probably you created a NSString @"@total" which sounds like a bug. You should be able to access it with:
[dict objectForKey:@"@total"];
Upvotes: 2