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

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