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 Objective-C Basics (Retired) Foundation Framework NSNumber

Declare another variable named 'planck' of type NSNumber and assign it the value 6.626.

Why is this wrong? I can't for the life of me find the syntax error here given the instructions above: NSNumber *planck = [[NSNumber alloc] initWithFloat:6.626];

4 Answers

Stone Preston
Stone Preston
42,016 Points

your code looks correct and I cant figure out why it wont work. Try using a literal like you did in the first task:

NSNumber *planck = @6.626;

The correct answer is just:

NSNumber *planck = @6.626;

I know, we were taught the other way using 'initWithFloat' on floats which made it confusing. -_-

NSNumber *aFloat = [NSNumber numberWithFloat:26.99f];

or

NSNumber *aFloat = @26.99F;
NSNumber *mike;
    //load a value into mike
    mike = [[NSNumber alloc] initWithInt:23]; //make it an integer number (initwithint)

This might help you out. Not the answer but might help :-)