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 trialRavid Yoeun
3,952 PointsCode Challenge: Declare another variable named 'planck' of type NSNumber and assign it the value 6.626.
I am stuck on this question and I believe I have the correct code however I keep getting the message that it is wrong.
This is what I have tried so far with no luck.
NSNumber *planck = [NSNumber numberWithDouble:6.626];
NSNumber *planck = [NSNumber numberWithFloat:6.626];
NSNumber *planck = @6.626;
NSNumber *planck; planck = [[NSNumber alloc] initWithFloat: 6.626];
Why won't any of these work?
4 Answers
Robert Bojor
Courses Plus Student 29,439 PointsHi Ravid,
This is the final code that passed that challenge...
NSNumber *foxtrot = @24;
NSLog(@"foxtrot %@", foxtrot);
NSNumber *planck = @6.626;
NSLog(@"planck %@", planck);
Robert Bojor
Courses Plus Student 29,439 PointsHi Ravid,
NSNumber *planck = [[NSNumber alloc] initWithFloat:6.626];
should have worked... can you pass me the challenge's url?
Thomas Nilsen
14,957 PointsIf he tries what you wrote it will work. He wrote:
NSNumber *planck; planck = [[NSNumber alloc] initWithFloat: 6.626];
Ravid Yoeun
3,952 PointsI also tried using NSNumber *planck = [[NSNumber alloc] initWithFloat:6.626]; with failure.
I think this may be a glitch or bug in the engine. Please have a look at the following link
Ravid Yoeun
3,952 PointsThank you robert!
Theo van den Berg
1,768 PointsSame problem here
gogqjmsqdy
7,769 PointsMy answer is the same as Robert. It did not pass. Looks like a bug. Please fix, thanks