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 trialAbdelGhafour Mohie
1,876 PointsRefactoring into a Model : Challenge
Why isn't my code working ?!:
<p>- (NSArray *) quotes {
if (_quotes == nil) {
_quotes = [[NSArray alloc] initWithObjects:@"Hey, @"Hi", @"Hello", nil];
}
return _quotes;
}</p>
2 Answers
Stone Preston
42,016 Points_quotes = [[NSArray alloc] initWithObjects:@"Hey, @"Hi", @"Hello", nil];
you are missing a closing double quote for your Hey string:
_quotes = [[NSArray alloc] initWithObjects:@"Hey", @"Hi", @"Hello", nil];
that should fix it.
AbdelGhafour Mohie
1,876 PointsThan a lot for you help. How annoying that you keep looking for you code for sometime trying to figure out what's wrong with your logic when it's just a typo or syntax error. Can'e even imagine when i start to make bigger applications.
Stone Preston
42,016 PointsFinding bugs and syntax errors is an art and takes practice. Eventually it will become easier and easier to find mistakes. Finding mistakes is especially tough in the code challenges since it doesn't tell you when you make an syntax error like Xcode does. You could write challenge code in Xcode first to help with catching syntax errors like this. I would also recommend trying to answer questions on the forum to help with learning to identify bugs and errors.
Stone Preston
42,016 PointsStone Preston
42,016 PointsWhen formatting code, you need to use backticks ( ` ) not single quotes ( ' ). Ive formatted your code for you so it appears correctly in the forum. The backtick key is just below the esc key on my keyboard. For more information on code formatting, see this post