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 trialMichael Henry
14,601 Pointsinitializing a mutable array
Hi folks -
I know that I am doing something wrong here (I'm trying to initialize a mutable array) - what is it???
Thanks!
'''
NSString *myString1 = @"one";
NSString *myString2 = @"two";
NSMutableArray *items = [NSMutableArray arrayWithObjects:myString1, myString2, nil];
'''
2 Answers
Amit Bijlani
Treehouse Guest TeacherYou are re-declaring the array. You are supposed to the use the property which was defined in the first task. Your code would look something like this:
self.items = [NSMutableArray arrayWithObjects:myString1, myString2, nil];
PS. For code formatting you need to use three backticks followed by the name of the language: ```objective-c
Michael Henry
14,601 PointsThanks, Amit. That makes sense. Regards, Mike