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.
Rodrigo Chousal
16,009 PointsWhat's wrong here?
Instructions: Declare another variable named 'planck' of type NSNumber and assign it the value 6.626.
My Code:
NSNumber *foxtrot;
foxtrot = [ [NSNumber alloc] initWithInt: 24];
NSLog (@"foxtrot %@", foxtrot);
NSNumber *planck;
planck = [ [NSNumber alloc] initWithInt: 6.626];
3 Answers

Stone Preston
42,016 PointsinitWithInt: 6.626]
6.626 is not an int, its a float
Rodrigo Chousal
16,009 PointsOh, so should I write initWithFloat?

Stone Preston
42,016 Pointsyeah try that. you could also use an NSNumber literal as well.
NSNumber myNumber = @1.5;
Rodrigo Chousal
16,009 PointsWhat about this?
Instructions:
Declare a third NSString variable named 'favorite' and assign a concatenated string to it by appending the variable named 'color' to the variable named 'preference'. (Remember to use the method 'stringByAppendingString').
My Code:
NSString *color = @"Purple";
NSString *preference = @"My favorite color is ";
NSString *favorite = [[preference stringByAppendingString : color]];

Stone Preston
42,016 PointsNSString *favorite = [[preference stringByAppendingString : color]];
you have too many brackets around the method call. Try
NSString *favorite = [preference stringByAppendingString:color];
Rodrigo Chousal
16,009 PointsYou are the best. Thank you!