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 trialOcky Wiemeijer
5,451 PointsWhat am I doing wrong?
The challenge is to declare another variable named planck and assign it the value of 6.626.
What is wrong about my code? It won't accept it, saying 'Make sure to assign the right value to planck'
NSNumber *foxtrot = [[NSNumber alloc] initWithInt:24];
NSLog(@"foxtrot %@", foxtrot);
NSNumber *planck = [[NSNumber alloc] initWithFloat:6.626];
2 Answers
Steve Hunter
57,712 PointsHi there,
I adopted a different approach using literals:
NSNumber *foxtrot = @24;
NSLog(@"foxtrot %@", foxtrot);
NSNumber *planck = @6.626;
NSLog(@"planck %@", planck);
This is passing the challenge.
Steve.
Ocky Wiemeijer
5,451 PointsThanks!!
Gabe Nadel
Treehouse Guest TeacherGabe Nadel
Treehouse Guest TeacherYes, the first step in the code challenge says explicitly, "using literal notation". The third step doesn't mention that. I'll be updating the quiz question to reflect that.
Thanks for helping to improve the Treehouse experience!
By the way, if you'd like a great summary of different literals in Obj-C:
https://www.codementor.io/ios/tutorial/introduction-to-objective-c-literals-for-ios-beginners