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 trial

iOS

Ravid Yoeun
Ravid Yoeun
3,952 Points

Code 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
PLUS
Robert Bojor
Courses Plus Student 29,439 Points

Hi 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
PLUS
Robert Bojor
Courses Plus Student 29,439 Points

Hi Ravid,

NSNumber *planck = [[NSNumber alloc] initWithFloat:6.626];

should have worked... can you pass me the challenge's url?

Thomas Nilsen
Thomas Nilsen
14,957 Points

If he tries what you wrote it will work. He wrote:

NSNumber *planck; planck = [[NSNumber alloc] initWithFloat: 6.626];
Ravid Yoeun
Ravid Yoeun
3,952 Points

I 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

http://teamtreehouse.com/library/nsnumber

My answer is the same as Robert. It did not pass. Looks like a bug. Please fix, thanks