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 Self-Destructing Message iPhone App Designing and Starting the App Introducing the Project

Designing and starting the App

Challenge task 2 of 2

Now switch to the implementation file and set the 'items' property to an array of two or more NSString objects using the 'arrayWithObjects' method of the NSMutableArray class.

My code (Line #4):

import "UITableViewController.h"

@interface InboxViewController : UITableViewController

@property (strong, nonatomic) NSMutableArray *items;

NSMutableArray *items = [arrayWithObjects:@"one",@"two"];

@end

Result:

Bummer! Compilation Error! Remember to use 'self' to reference your property and to set it as an NSMutableArray.

2 Answers

Adam Hill
Adam Hill
7,492 Points

Hi Joey,

Roberts right, you need to switch to the .m file and I can't remember how I got to the right answer, but I found another solution here:-

https://teamtreehouse.com/forum/initiating-nsmutablearray-with-arraywithobjects-method

self.items = [NSMutableArray arrayWithObjects:@"one string", @"another string", @"third string", nil]
Robert Bojor
PLUS
Robert Bojor
Courses Plus Student 29,439 Points

Hi Joey,

As the challenge says, you should change to the implementation file ( the .m file ) and there you should add the definition of the array.

NSMutableArray *items = [arrayWithObjects:@"one",@"two"];