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

thanh trung
thanh trung
4,246 Points

having problem with this ex

<code>NSArray *booksArray = [NSArray arrayWithObjects:@"Hamlet", @"King Lear", @"Othello",@"Macbeth", nil]; NSString *bookTitle = [self.booksArray objectAtIndex:indexPath.row]; </code>

thanh trung
thanh trung
4,246 Points

what did i do wrong here?

Greg Barbosa
Greg Barbosa
9,874 Points

Check my answer below and let me know if it helps :)

3 Answers

Hi,

I can't remember this exercise. What is the error message you receive?

Just a fair guess, have you specified booksArray as a private or public property of you class?

Bye

Greg Barbosa
Greg Barbosa
9,874 Points

Thanh, Here is the code you provided:

NSArray *booksArray = [NSArray arrayWithObjects:@"Hamlet", @"King Lear", @"Othello",@"Macbeth", nil]; 
NSString *bookTitle = [self.booksArray objectAtIndex:indexPath.row];

But the question is asking you to set the bookTitle to the third object in the booksArray. You are very close, but pay attention to what you have written after objectAtIndex. indexPath.row is used in conjunction when working with table view cells, which in this Code Challenge I don't believe you are.

NSArray *booksArray = [NSArray arrayWithObjects:@"Hamlet", @"King Lear", @"Othello",@"Macbeth", nil]; 
NSString *bookTitle = [self.booksArray objectAtIndex:**CHANGE YOUR CODE HERE**];
thanh trung
thanh trung
4,246 Points

thanks but i have done it. it should be [booksArray objectAtIndex:2]; thanks anyway for answering