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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![busterlabs](https://uploads.teamtreehouse.com/production/profile-photos/1526212/micro_photo.png)
busterlabs
9,276 PointsExploring the Master Detail Template
Challenge # 3
Now make the 'bookTitle' upper case.
My code:
NSCharacterSet *bookTitle = [NSCharacterSet uppercaseLetterCharacterSet, bookTitle];
Result:
Bummer! You need to call a method on the instance variable 'bookTitle'.
Is it me, or all three challenges were not shown / discussed in the previous video??? I don't see where this challenge came from!
9 Answers
![Chris Shaw](https://secure.gravatar.com/avatar/89a81f4cc3cec373f6a1547fde9e8c26?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Chris Shaw
26,676 PointsHi Joey,
This example would have come from the iOS basics course, the code you have above won't work as the task is asking for NSString
while you're trying to set a type of NSCharacterSet
for bookTitle
, the simplest way to transform a string into all caps is by calling the uppercaseString
method directly on the string itself like the below example which eliminates the need to set the value again and cleans up any clutter in our code.
NSString *bookTitle = [[booksArray objectAtIndex:2] uppercaseString];
Hope that helps =)
![busterlabs](https://uploads.teamtreehouse.com/production/profile-photos/1526212/micro_photo.png)
busterlabs
9,276 PointsThanks John. However, I got this message next:
Bummer! You need to call a method on the instance variable 'bookTitle'.
Any suggestions?
![Chris Shaw](https://secure.gravatar.com/avatar/89a81f4cc3cec373f6a1547fde9e8c26?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Chris Shaw
26,676 PointsCould you please post the code you're using for the challenge
![busterlabs](https://uploads.teamtreehouse.com/production/profile-photos/1526212/micro_photo.png)
busterlabs
9,276 PointsNSString *bookTitle = [[booksArray objectAtIndex:@"Othello"] uppercaseString];
![Chris Shaw](https://secure.gravatar.com/avatar/89a81f4cc3cec373f6a1547fde9e8c26?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Chris Shaw
26,676 PointsYour above code won't work as you're passing a string literal to objectAtIndex
which only accepts an integer or in this case the index of the item you want to select.
In the example I posted above I'm selecting the second index of the booksArray
which in reality the 3rd item in the array.
![busterlabs](https://uploads.teamtreehouse.com/production/profile-photos/1526212/micro_photo.png)
busterlabs
9,276 PointsNSString *bookTitle = [[booksArray objectAtIndex:2] uppercaseString]; didn't work either
![Chris Shaw](https://secure.gravatar.com/avatar/89a81f4cc3cec373f6a1547fde9e8c26?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Chris Shaw
26,676 PointsWhat does your NSArray look like? Could you please post that.
![Jacob McLaws](https://uploads.teamtreehouse.com/production/profile-photos/1429702/micro_profile_profile.jpg)
Jacob McLaws
1,497 PointsIt worked for me. Thanks John!
![Chris Shaw](https://secure.gravatar.com/avatar/89a81f4cc3cec373f6a1547fde9e8c26?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Chris Shaw
26,676 PointsNo problem but who's John? =)
![busterlabs](https://uploads.teamtreehouse.com/production/profile-photos/1526212/micro_photo.png)
busterlabs
9,276 PointsHi Chris,
Here's my first 2 lines of code:
NSArray *booksArray = [NSArray arrayWithObjects:@"Hamlet", @"King Lear", @"Othello", @"Macbeth", nil];
NSString *bookTitle = booksArray[2];
![Chris Shaw](https://secure.gravatar.com/avatar/89a81f4cc3cec373f6a1547fde9e8c26?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Chris Shaw
26,676 PointsHi Joey,
I just tried the following and had no problem passing the task, based on the above code you will continue to get an error message as your're not converting the string to uppercase.
NSArray *booksArray = [NSArray arrayWithObjects:@"Hamlet", @"King Lear", @"Othello", @"Macbeth", nil];
NSString *bookTitle = [[booksArray objectAtIndex:2] uppercaseString];
Also because this is an intermediate course I would recommend creating the NSArray
using a literal which is easier to work with and read.
NSArray *booksArray = @[@"Hamlet", @"King Lear", @"Othello", @"Macbeth"];
![busterlabs](https://uploads.teamtreehouse.com/production/profile-photos/1526212/micro_photo.png)
busterlabs
9,276 PointsI'm sorry but that still doesn't work...
NSString *bookTitle = [[booksArray objectAtIndex:2] uppercaseString];
Bummer! You need to call a method on the instance variable 'bookTitle'.
![Chris Shaw](https://secure.gravatar.com/avatar/89a81f4cc3cec373f6a1547fde9e8c26?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Chris Shaw
26,676 PointsWhich task is it failing on as I just tried it again with no problems occurring. Also during the challenge could you please take a screenshot of each task up until the one that fails as the code I posted previously works flawlessly for me.
![busterlabs](https://uploads.teamtreehouse.com/production/profile-photos/1526212/micro_photo.png)
busterlabs
9,276 PointsHow do I show you the screenshots? I can't paste them here
![Chris Shaw](https://secure.gravatar.com/avatar/89a81f4cc3cec373f6a1547fde9e8c26?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Chris Shaw
26,676 PointsYou can upload them to a service such as imgur and paste the share links.
![busterlabs](https://uploads.teamtreehouse.com/production/profile-photos/1526212/micro_photo.png)
busterlabs
9,276 PointsDo you have a treehouse email add instead?
![Chris Shaw](https://secure.gravatar.com/avatar/89a81f4cc3cec373f6a1547fde9e8c26?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Chris Shaw
26,676 PointsHi Joey,
It appears you got this solved in another thread https://teamtreehouse.com/forum/master-detail, in the context of the original question the first answer I gave did solve the issue but I think you confused what I initially said with what you were doing.
So it doesn't completely get lost in translation let's break it down.
- Task 1 asks for an
NSArray
with the specified values.
NSArray *booksArray = @[@"Hamlet", @"King Lear", @"Othello", @"Macbeth"];
- Task 2 then asks you to select the second index from the array and assign it to bookTitle
NSString *bookTitle = [booksArray objectAtIndex:2];
// OR
NSString *bookTitle = booksArray[2];
- Task 3 then asks you to convert the string to uppercase which my answer was simply supposed to go over the top of what you already had resulting in.
NSArray *booksArray = @[@"Hamlet", @"King Lear", @"Othello", @"Macbeth"];
NSString *bookTitle = [[booksArray objectAtIndex:2] uppercaseString];
I'm sorry for any confusion but given this was an intermediate course I didn't see a need to show the full code example, again sorry for any confusion.