Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ee Ren
272 Points(Master-Detail Template) Create an array named 'booksArray' with the following book titles : 'Hamlet', 'King Lear', 'Othello', 'Macbeth'.
Can someone please help me out ? I can't understand the question. I don't know which part I should start to code at.
3 Answers

Chris Rhode
1,447 PointsHi
This is an exercise in NSArray Literals - you can type it in a couple of different ways to get the same result
Type1 NSArray *array name = [[NSArray alloc] initWithObjects:@"array name 1",@"array name 2",......,nil];
Type2 NSArray *array name = [NSArray arrayWithObjects:@"array name 1",@"array name 2",......,nil];
I believe there may even be a shorter way of doing it but can't remember off the top of my head

Guyen Pham
Courses Plus Student 2,820 PointsI have the same question, I thought I did right but dont know why what's wrong here. Can somebody please help me?
self.booksArray = [NSArray arrayWithObjects:
@"Hamlet",
@"King Lear",
@"Othello",
@"Macbeth",
nil];
```

Aaron Arkie
5,345 PointsHello, it should be in a form like this.. i'm not sure about objective C as i'm more familiar with Java but it should be similar. So its telling you to make an array called booksArray and its values are that of a string so first lets declare the array and what datatype it holds.
Form:
arraytype[] arrayname;
substitute the values:
String[] booksArray;
lastly set the book titles as a string to the array which should end up looking like this:
Form:
arraytype[] arrayname = {string,string,string,string};
again substitute the values;
String[] booksArray = {"Hamlet", "King Lear", "Othello", "Macbeth"};
and that wraps it up i hope that helps.