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 Build a Blog Reader iPhone App Exploring the Master-Detail Template Modifying the Master-Detail Template

I can't get passed the task that requires me to create an array with given entry titles although everything seems legit.

I don't understand what is wrong with my code. The task requires me to create an array named 'booksArray' and pass it the values that I've given it. I'm only getting an error which tells me to check my syntax or variable name.

arrays.mm
NSArray *booksArray = @[@"Hamlet", "King Lear", @"Othello", @"Macbeth", nil];

4 Answers

This is what I passed with:

NSArray *booksArray = [[NSArray alloc] initWithObjects:@"Hamlet", @"King Lear", @"Othello", @"Macbeth", nil];

Code challenges can be finicky, so even though I think your code is legitimate, it's not what they wanted.

Ah yes, thank you. Managed to pass it with your code although I tried using several different approaches including this one prior to asking a question.

I'm glad you got it!

Usage of a better method, combining your initialization and assignment:

NSArray *booksArray = [NSArray arrayWithObjects: @"Hamlet", @"King Lear", @"Othello", @"Macbeth", nil];

is this objective-c?

Objective-c, yes but I managed to clear the task already :)

is this objective-c?

Yes, the code above is in Objective-C