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 trialRodrigo 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!