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 trialVidit Shah
6,037 PointsNSString Task
NSString *color=@"Purple"; NSString *preference=@"My favorite color is"; NSString *favorite=[color stringByAppendingString:preference]; NSLog(@" %@",favorite);
//Its perfectly working in Xcode.But not in The environment provided by Treehouse.
5 Answers
Vidit Shah
6,037 PointsTask is asking me to use method :StringByAppending String
Camilo Castro
Courses Plus Student 2,549 Pointsuse NSMutableString instead of NSString
NSMutableString * color = @"Purple";
Vidit Shah
6,037 PointsBut thats not yet taught..!
Vidit Shah
6,037 PointsBRO everything is working fine is Xcode but in the compiler provided by them it states, Bummer! Make sure to assign the correct value to 'favorite'.
Camilo Castro
Courses Plus Student 2,549 PointsI think the correct answer should be
My favorite color is Purple
But in your code shows
PurpleMy favorite color is
as the answer
Vidit Shah
6,037 PointsYa that was correct :P.
Vidit Shah
6,037 PointsThank You so much
Camilo Castro
Courses Plus Student 2,549 PointsYou are welcome, Please mark my answer as correct, so I can get the points :D
Camilo Castro
Courses Plus Student 2,549 PointsCamilo Castro
Courses Plus Student 2,549 PointsI tried your code in Xcode
The result is
PurpleMy favorite color is
If you change favorite to this
NSString * favorite = [preference stringByAppendingString:color];
You got
My favorite color isPurple
Add a space to preference
NSString * preference = @"My favorite color is ";