Welcome to the Treehouse Community
Looking to learn something new?
cameryn smith2,828 Points
How do you add strings to a declared NSMutableArray?
Add the following strings to the ‘elements’ array: 'Helium','Neon', 'Argon'
I'm lossed -____- LOL
NSMutableArray *elements = [NSMutableArray array];
//Now here is where I get stuck
Nick Sint4,208 Points
The solution to your problem is quite simple.
You created an array called elements therefore this is the array you want to add all your objects in.
Note, the method you called addObject: is literally what it says, you add an object to the array. Specifically 1 object at a time. So if you want to add 3 objects, you need to call it 3 times.
So you have 2 choices if you want to create an array called elements with 3 objects ('Helium','Neon', 'Argon').
NSMutableArray *elements = [[NSMutableArray alloc] initWithObjects:@"Helium",@"Neon",@"Argon",nil];
NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"Helium"]; [elements addObject:@"Neon"]; [elements addObject:@"Argon"];