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

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!