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 Code Challenge 3/3 "Task 1 is no longer passing"

I'm receiving the error "Task 1 is no longer passing" when trying to complete part 3/3 of the Code Challenge (making the book title contained in *bookTitle uppercase). Here's my passing code for 2/3:

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

NSString *bookTitle = booksArray[2];

For part 3/3, if I attempt to do almost anything with the bookTitle pointer, it gives me the "Task 1 no longer passing" error. For instance:

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

NSString *bookTitle = booksArray[2];
NSString *string2 = bookTitle.uppercase;

generates the error. I looked it up just be sure: the .uppercase method of NSString returns an uppercase copy of the object, correct? So making a new pointer aimed at bookTitle.uppercase should leave bookTitle unchanged.

1 Answer

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

The method to convert a string to uppercase is called uppercaseString. And if you are calling a method on an object then you must use this format: [bookTitle uppercaseString]. The dot syntax is usually reserved for properties.

Thank you so much for your quick response! Are dot syntax and bracket syntax technically interchangeable, but used differently as a convention? And does [someString uppercaseString] return a new string, or modify the calling string in place? (The solution to the third part of the challenge was simply [bookTitle uppercaseString], which lead me to believe that it modified the string in place, but the documentation seems to say the opposite (though it isn't totally clear.)

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

No, the string is not modified in place, it does return a new string. The Code Challenges are there just to prove you know how to call the proper method on the class which leads to a bit of a disconnect from what you would do in a real world app.

As for the bracket and dot syntax. You generally want to use the dot notation when accessing a property and the bracket syntax when calling a method. This way when you are looking at your code you can easily discern between a method and a property.

Thanks so much for your help!