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

Confused on Part #3 of this Challenge

Can someone show me what code it is asking me to input? I find the directions for this step kind of confusing and cannot seem to get it right. For my third step this is what I'm typing in, and it says it is incorrect. Any help is appreciated!

NSString *favorite = [[color stringByAppendingString:preference]];

1 Answer

Stone Preston
Stone Preston
42,016 Points

you have too many brackets around your method call and your strings are reversed. string by appending string appends the string you pass in as an argument to the end of the string thats calling the method

NSString *favorite = [preference stringByAppendingString:color];

will output My favorite color is purple.

NSString *favorite = [[color stringByAppendingString:preference]];

would output purpleMy favorite color is.