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 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];


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 :-)