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

Naftali Beder
Naftali Beder
927 Points

Getting error on challenge 3/4 and don't see why.

For challenge 3/4, I put in

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

and get an error. In Xcode the statement works correctly. Am I doing something wrong, or is the Treehouse challenge wrong?

2 Answers

It seems that the challenge expects the number to be a double and not float.

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

worked for me.

NSNumber *planck = @6.626;

should work also.

Naftali Beder
Naftali Beder
927 Points

Yup some googling just showed that a lot of people have been confused about that question, I probably should've looked around first. I used initWithDouble and it worked.

Thanks!