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 trialthanh trung
4,246 Pointshaving problem with this ex
<code>NSArray *booksArray = [NSArray arrayWithObjects:@"Hamlet", @"King Lear", @"Othello",@"Macbeth", nil]; NSString *bookTitle = [self.booksArray objectAtIndex:indexPath.row]; </code>
Greg Barbosa
9,874 PointsCheck my answer below and let me know if it helps :)
3 Answers
Sebastian Döll
24,464 PointsHi,
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
9,874 PointsThanh, 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
4,246 Pointsthanks but i have done it. it should be [booksArray objectAtIndex:2]; thanks anyway for answering
thanh trung
4,246 Pointsthanh trung
4,246 Pointswhat did i do wrong here?