Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Object-Oriented Objective-C Getting Oriented - Object-Oriented, That Is NSDictionary and NSMutableDictionary cont.

Yevhen Kim
Yevhen Kim
6,134 Points

in 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
Nicholas Ellis
5,383 Points

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

Because you put your break point above the last line code [outputDict setValue ......].

Andrew Byerly
Andrew Byerly
1,157 Points

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