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

help!! 3/3

hey! i am trying to do the Modifying the master detail template but i keep getting stuck on the last thing!! can someone help? it says i need to capitalise it so here is my code

NSArray *booksArray = [[NSArray alloc]initWithObjects:@"Hamlet", @"King Lear", @"Othello", @"Macbeth", nil]; NSString *bookTitle = [[booksArray objectAtIndex:2] bookTitle uppercaseString];

then i tried to make it like this:

NSArray *booksArray = [[NSArray alloc]initWithObjects:@"Hamlet", @"King Lear", @"Othello", @"Macbeth", nil]; NSString *bookTitle = [booksArray objectAtIndex:2]; bookTitle = [bookTitle uppercaseString];

and that didn't work so i then tried this:

NSArray *booksArray = [[NSArray alloc]initWithObjects:@"Hamlet", @"King Lear", @"Othello", @"Macbeth", nil]; NSString *bookTitle = [booksArray objectAtIndex:2]; [bookTitle uppercaseString];

but i still don't know what is wrong can someone help me?!

7 Answers

ok. your problem is you already have a bookTitle string declared, you dont have to declare it again

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

NSString *bookTitle = [booksArray objectAtIndex:2];

//bookTitle is now all uppercase
[bookTitle uppercaseString];

Can you provide a link to the challenge?

its already capitalized in the literal value in your array so shouldnt have to call any additional methods to capitalize it. did you try

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

NSString *bookTitle = [booksArray objectAtIndex:2]

it says uppercase :) sorry!

i just did what you did and it said this "Bummer! There was no method called to convert the string to uppercase." am i being really silly?

sorry, I thought you were on task 2 for a minute. see my other post below about what you did wrong

thank you so much!!!!!!!! it worked!!! i wonder why it didn't the first time haha!

no problem. the challenge most likely wanted it in 2 separate lines in order to keep the code for task 2 and task 3 separate.

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

//task 2 code
NSString *bookTitle = [booksArray objectAtIndex:2];

//task 3 code
//bookTitle is now all uppercase
[bookTitle uppercaseString];

whereas at first you had

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

//you combined task 2 and 3 code into one line, so the challenge thinks task 2 is no longer passing
NSString *bookTitle = [[booksArray objectAtIndex:2] bookTitle uppercaseString];

It gives the correct output, but task2 is expecting the bookTitle to be @"Othello", not @"OTHELLO" so the challenge thinks task 2 is no longer passing.

thanks!! i understand it now :)