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 trialJudah Morales
2,481 PointsobjectAtIndex questions
I'm pretty sure I'm doing this challenge correctly but it keeps coming back with an issue. I'm not sure why this wouldn't work. Any help?
NSArray *booksArray = [NSArray arrayWithObjects:@"Hamlet", @"King Lear", @"Othello", @"Macbeth", nil];
NSString *bookTitle = [self.booksArray objectAtIndex:2];
The challenge is to create an array, then create a string and add the 3rd item in the array to the string.
Thanks in advance!
2 Answers
Sam Roth
1,457 PointsNSArray *booksArray = @[ @"Hamlet", @"King Lear", @"Othello", @"Macbeth"];
NSString *bookTitle = [booksArray objectAtIndex:2];
Hi Judah,
When setting *bookTitle to the third index of the *booksArray, you don't need to do a self declaration. The above code will validate.
Judah Morales
2,481 PointsThanks Samuel. I appreciate the assistance. Now I need to research why, lol.