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.

iOS Build a Blog Reader iPhone App Getting Data from the Web What is NSDictionary?

Ludwing Najera
Ludwing Najera
4,596 Points

Code Challenge Problem?

i was on this code challenge and t asked me to add an NSArray, but wouldn't you have to declare it in the .h file? the code challenge did not show a .h file anywhere.

this is my code:

NSDictionary *book1 = [NSDictionary dictionaryWithObjectsAndKeys:@"Art of War", @"Title", @"Sun Tzu", @"Author",nil]; NSDictionary *book2 = [NSDictionary dictionaryWithObjectsAndKeys:@"BraveNew World", @"Title", @"Aldous > Huxley", @"Author",nil];

self.booksArray = [NSArray arrayWithObjects: book1, book2, nil];

is it a problem with the Code Challenge?

1 Answer

NSDictionary *book1 = [NSDictionary dictionaryWithObjectsAndKeys:@"Art of War", @"Title", @"Sun Tzu", @"Author", nil]; NSDictionary *book2 = [NSDictionary dictionaryWithObjectsAndKeys:@"Brave New World", @"Title", @"Aldous Huxley", @"Author", nil]; NSArray *booksArray = [NSArray arrayWithObjects:book1,book2,nil];

you need to declare the NSArray and the variable name "booksArray". you only do self.bookArray if a @property was declared in the .h file