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 Simple iPhone App (iOS7) Creating a Data Collection Create an NSArray Property

Ryan Cocuzzo
Ryan Cocuzzo
1,206 Points

Code returning incorrect, anybody got any ideas?

self.quotes = [[NSArray alloc] initWithObjects: 
@"Haters gonna hate", @"Life is simple, not easy", 
@"Winners never quit, quitters never win", nil];

2 Answers

Aymeric Gallissot
Aymeric Gallissot
7,726 Points

The response for your problem:

self.quotes = [[NSArray alloc] initWithArray:@[@"Haters gonna hate", @"Life is simple, not easy", @"Winners never quit, quitters never win"]];
Ryan Cocuzzo
Ryan Cocuzzo
1,206 Points

I tried that exact code and it did not work

Aymeric Gallissot
Aymeric Gallissot
7,726 Points

I tried the exercise and it works for me. Check the console error message.

Aymeric Gallissot
Aymeric Gallissot
7,726 Points

You can do just like this

self.quotes = @[@"Haters gonna hate" @"Life is simple, not easy", @"Winners never quit, quitters never win"];
Ryan Cocuzzo
Ryan Cocuzzo
1,206 Points

This did code did not work, do you have other suggestions?