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

Master Detail

My code for Challenge #1 and #2:

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

NSString *bookTitle = booksArray[2];

Challenge # 3

Now make the 'bookTitle' upper case.

My code for #3:

NSString *bookTitle = [[booksArray objectAtIndex:2] uppercaseString];

Result:

Bummer! You need to call a method on the instance variable 'bookTitle'.

Been stuck on this challenge for a few days already and nobody seems to know why this code is not working for me and does for others

2 Answers

Stone Preston
Stone Preston
42,016 Points

Without looking at the actual challenge I cant tell you exactly whats wrong, but I have a hunch:

NSString *bookTitle = booksArray[2];

here you create a string object named bookTitle. in task 3 you need to modify that SAME variable so you would use:

[bookTitle uppercaseString];

putting that together gives you:

NSString *bookTitle = booksArray[2];
[bookTitle uppercaseString];

before you were doing this

NSString *bookTitle = booksArray[2];
NSString *bookTitle = [[booksArray objectAtIndex:2] uppercaseString];

which defines and assigns a variable named bookTitle, then redefines and assigns it again. While technically this would work, the challenge wanted you to modify the variable you created in the previous task, not redefine it.

Thanks Stone Preston! You're the man!