Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialYevhen Kim
6,134 Pointsin console NSDictionary shows @"subtotal" : (no summary)
code inside of Main:
NSDictionary *orderDict = @{ @"burgers": @5, @"shakes": @3, @"customers": @4, @"isTakeOut": @NO, @"subtotal": @0.0, };
float burgerPrice = 4;
float shakePrice = 3;
float subtotal;
subtotal = (burgerPrice * [[orderDict valueForKey:@"burgers"]intValue]) + (shakePrice * [[orderDict valueForKey:@"shakes"]intValue]);
NSMutableDictionary *outputDict = [NSMutableDictionary dictionaryWithDictionary:orderDict];
[outputDict setValue:@(subtotal) forKey:@"subtotal"];
Console result:
burgerPrice float 4
subtotal float 29
orderDict __NSDictionaryI * 5 key/value pairs 0x0000000100400940
[0] (null) @"shakes" : (int)3
[1] (null) @"customers" : (int)4
[2] (null) @"subtotal" : (no summary)
key __NSCFConstantString * @"subtotal" 0x00000001000010d0
value __NSCFNumber * 0x57 0x0000000000000057
NSNumber NSNumber
NSValue NSValue
NSObject NSObject
isa Class 0x0
[3] (null) @"isTakeOut" : @"0"
[4] (null) @"burgers" : (int)5
shakePrice float 3
outputDict __NSDictionaryM * 5 key/value pairs 0x0000000100400b30
3 Answers
Nicholas Ellis
5,383 PointsIt may be because you have Xcode 7.3.1, it would show up the same as his if your Xcode was 7.2 but it would not show up the same if you had the most recent version.
nhannguyen7
1,864 PointsBecause you put your break point above the last line code [outputDict setValue ......].
Andrew Byerly
1,157 PointsI'm having the same thing happen. My code is exactly how it is shown in the example, but my NSDictionary gets defined with (no summary) for subtotal. The output Dict gets a subtotal value of (short)29