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 Getting Data from the Web Mutable vs Immutable

Code challenge: Mutable vs. Immutable 4 of 4

I test my code in Xcode it works but still wrong in this challenge.

NSMutableArray *elements = [NSMutableArray array];
elements = [ NSMutableArray arrayWithObjects:@"Helium",
                    @"Neon",
                    @"Argon",@"Will",nil];
[elements removeObjectAtIndex:1];
[elements removeObjectAtIndex:[elements count]-1];

1 Answer

Stone Preston
Stone Preston
42,016 Points

your code is correct, however it seems the challenge is expecting you to use the removeLastObject instance method of NSMutableArray, instead of using the count method. so try using the removeLastObject method instead

you should also remove that extra object you have in your array: @"will", you dont need that

[ NSMutableArray arrayWithObjects:@"Helium", @"Neon", @"Argon",nil];

Thanks, Stone.