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 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