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 NSString

Michael Curtis
Michael Curtis
6,684 Points

Can't get the final challenge in the NSStrings code challenge. Any help?

The question states: 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').

I can't seem to get this one even after re-watching the video any help with what I've missed would be appreciated.

string.mm
NSString *color = @"Purple";
NSString *preference = @"My Favorite";

NSString *favorite = [preference stringByAppendingString:color];

1 Answer

Greg Kaleka
Greg Kaleka
39,021 Points

Hi Michael,

I'm not sure how you passed the second challenge. You were supposed to assign preference the value "My favorite color is ", not "My Favorite". That's your only issue. You're calling the method correctly.

Douglass Turner, it might be good to adjust the Challenge 2 checking :).

Cheers,

Greg

Michael Curtis
Michael Curtis
6,684 Points

Many thanks as it let me pass part two i hadn't thought to look there.