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!
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
Sam Chaudry
25,519 PointsCrystal Ball - Code Challenge > Creating a Data Collection > Create an NSArray Property
On the code challenge for Creating data collection badge the compiler seems to be crashing all the time, not sure why. I've added my code for each of three steps, any chance someone can point me in the right direction?
Stage 1@property (nonatomic, strong) NSArray * quotes;
Stage 2 self.quotes= [[NSArray alloc]initWithObjects:@"Haters gonna hate", @"It is decidedly so", @"Life is simple, not easy", @"Winners never quit, quitters never win", Nil];
Stage 3 self.quotes.text= [quotes objectAtIndex:2];
21 Answers

Sam Chaudry
25,519 PointsGlad you finished Antonio, I just logged in and saw the alert, try to be a bit more helpful next time

GRAYSON D SMITH
1,547 PointsThe directions are wrong in this task. Nowhere does it ask you to use "It is decidedly so"...

Amit Bijlani
Treehouse Guest TeacherI think Sam just added that in but it is not supposed to be part of the answer.

GRAYSON D SMITH
1,547 PointsThanks Amit.. yeah, not sure what was up. I was having some problems until I added that line in

Amit Bijlani
Treehouse Guest TeacherIn task 3 you have to assign the quote to the label which is called 'quoteLabel' not 'quotes'.

Sam Chaudry
25,519 PointsHi I just put in self.quoteLabel.text= [quotes objectAtIndex:2] it still seems to be crashing. Not sure what I'm doing wrong here?

Amit Bijlani
Treehouse Guest TeacherThe array 'quotes' is a property so you have to refer to it as 'self.quotes'.

Sam Chaudry
25,519 PointsHi Amit I had another go at it and I still got an error as well as a message stating to contact the help desk. This is the code I've inputted in self.quoteLabel.text= [self.quotes objectAtIndex:1]; If you could explain what I'm doing wrong that would be much appreciated

Amit Bijlani
Treehouse Guest TeacherYour syntax is fine now. I just realized that when you initialized your array you added "It is decidedly so" as your second item while it is expecting "Life is simple, not easy".

Sam Chaudry
25,519 PointsAwesome that sorted it out. Thanks Amit

Angel Cepeda
3,735 PointsLet me also add that I was trying to figure out the problem with my code for about an hour. The problem with my code was that I did not capitalize the 'L' in 'Life'. This caused my work to be wrong. Beware!

Amit Bijlani
Treehouse Guest TeacherSorry about that, I have modified the challenge to be a bit more lenient.

Sam Chaudry
25,519 PointsThanks Angel great tip

Antonio Fullone
1,019 PointsI'm trying to do this task but I always get an error : I do the exact same thing : 1step - @property (nonatomic, strong) NSArray *quotes; 2step - self.quotes = [NSArray alloc] initWithObjects: @"Haters gonna hate", @"Life is simple, not easy", @"Winners never quit, quitters never win", Nil]; and then it says : "Oops! It looks like Task 1 is no longer passing.". I've lost half hour on this but cannot understand where I am doing wrong, I also re-watched the video. What am I doing wrong?

Emmanuel Darmon
6,115 PointsI think it's an error, but if you add @"It is decidedly so" in your code, it will work out! @"Haters gonna hate", @"It is decidedly so", @"Life is simple, not easy", @"Winners never quit, quitters never win", Nil];

Antonio Fullone
1,019 PointsI finally solved it, I was missing to add the string "@"It is decidedly so", thanks to this post I found out the reason.
Maybe I missed out something but this is the description of the task :
Switch to the implementation file. Within the 'viewDidLoad' method allocate and initialize the 'quotes' property to the following quotes: 'Haters gonna hate', 'Life is simple, not easy', 'Winners never quit, quitters never win'.
I added the string and finished the task. :)

Daniel Demciuc
Courses Plus Student 1,900 Points''' Stage 1@property (nonatomic, strong) NSArray * quotes;
Stage 2 self.quotes= [[NSArray alloc]initWithObjects:@"Haters gonna hate", @"Life is simple, not easy", @"Life is simple, not easyIt is decidedly so", @"Winners never quit, quitters never win", Nil];
this is wrong-->Stage 3 self.quotes.text= [quotes objectAtIndex:2]; this is right-->Stage 3 self.quoteLabel.text = [self.quotes objectAtIndex:1];
'''

Stu Cowley
26,287 PointsThanks guys, this one has been really annoying me. Stupid me had written down my notes wrong :-\

Sam Chaudry
25,519 PointsYeah I decided to put that in just to shake things up lol. Apologies if it seem confusing....

nawrouz karim
1,295 Pointsi am at stage 3 and the code below hits back an error, this is the same syntax from my program on Xcode so i don't understand where i'm going wrong with it.
self.quoteLabel.text = [self.quotes objectAtIndex:1];

GRAYSON D SMITH
1,547 PointsThat actually looks right to me too Nawrouz. Maybe check to make sure you didn't change anything else by mistake?

Ghaz Sabh
5,005 PointsI'm so done with stupid code challenge things, I'm going to cancel my course with tree house. Thats my best answer, I spent more times trying to figure out where is the issue can't find. Good luck guys.

Amit Bijlani
Treehouse Guest TeacherWe are here to help you. All you need to do is share your code and where you were having trouble and we'd gladly point you in the right direction. It can be hard initially but once you get a hang of the concepts and syntax it will get easier.

Ghaz Sabh
5,005 PointsThank you so much for your replay Amit, I'm stuck on task 2, not sure how task 3 will be :)
self.quotes = [[NSArray alloc] initWithObjects: @"Haters gonna hate", @"Life is simple, not easy", @"Life is simple, not easy It is decidedly so", @"Winners never quit, quitters never win", Nil];

Amit Bijlani
Treehouse Guest TeacherI copied and pasted your code above and it passed for Task 2. Did you make sure to switch over to the THViewController.m
and enter your code within the viewDidLoad
method?

Tsan Kuo
Courses Plus Student 1,931 Pointsin stage1, when i tried :
@property (nonatomic, strong) NSString *quotes;
and it passed.. dunno if its a bug for it
:)
thanks Amit, I've learned a lot from you!(guys)

Iurii Paterega
Courses Plus Student 1,441 Pointsstage 3. self.quoteLabel.text=[self.quotes objectAtIndex:1]; where is the problem?

Michael Maloof
4,581 PointsCan someone please add the final coding for all three stages? All the instructional errors involved in the question have made the forum really confusing to read. Thanks guys (still a great lesson btw).

nan zhou
Courses Plus Student 18,273 PointsHere is my answer for stage 2 and 3. It successfully passed the challenge.
// Stage 2
self.quotes= [[NSArray alloc]initWithObjects:@"Haters gonna hate", @"Life is simple, not easy", @"Winners never quit, quitters never win", Nil];
//Stage 3
self.quoteLabel.text = [self.quotes objectAtIndex:1];