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 Exploring the Master-Detail Template Modifying the Master-Detail Template

Lex Lawless
Lex Lawless
1,773 Points

The Quiz doesn't accept my Array

I put the following:

self.booksArray = [NSArray arrayWithObjects:@"Hamlet",@"King Lear",@"Othello",@"Macbeth", nil];

It keeps complaining that I din't use the array name "booksArray" or there's something wrong with the syntax.

Can anyone give me some help?

4 Answers

Lex Lawless
Lex Lawless
1,773 Points

Okay, I went back to a previous lesson on NSArray and typed in the following that worked.

NSArray *booksArray = @[@"Hamlet",@"King Lear",@"Othello",@"Macbeth"];

However, Amit uses the:

self.booksArray = [NSArray arrayWithObjects:@"Hamlet",@"King Lear",@"Othello",@"Macbeth", nil];

in the video so I was assuming I could use the way he coded the Array in the quiz! Very frustrating!

Stone Preston
Stone Preston
42,016 Points

the problem is that the challenge states: Create an array named 'booksArray' with the following book titles: 'Hamlet', 'King Lear', 'Othello', 'Macbeth'.

it asks you to create an array. just an array, it does NOT say to use an array property (there isnt one). if it said to use the property booksArray then yes using self.booksArray would work. However in this case you are not using a property, which is why you dont use self.booksArray

Lex Lawless
Lex Lawless
1,773 Points

Easy for you to say if you understand all this. But this lesson is suppose to be for those who don't know.

Stone Preston
Stone Preston
42,016 Points

Objective c basics has a video on properties here that might help you understand it better

Ivan Kvyatkovskiy
Ivan Kvyatkovskiy
5,743 Points

The thing is: self.booksArray does not defined in this case, it might be of any type not just NSArray so since it is not of NSArray type you can't point to the value of your new array.

Christopher Dyer
Christopher Dyer
3,634 Points

After a few attempts, I entered: NSArray *booksArray = @[@"Hamlet",@"King Lear",@"Othello",@"Macbeth"];

And it did not work. The editor cursor was all over the place. I then spent ages trying everything including self....

A complete waste of time and utterly frustrating.

I will try a few more of these, but if this frustration is typical in your teaching style - goodbye Treehouse.

The solution is simple, give people a few goes and then provide the answer or hints.