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

Peter Fazekas
Peter Fazekas
896 Points

im stuck at the ios development crystal ball app challenge 3rd objective

this is my code and it still says an error please help

import "THViewController.h"

@implementation THViewController

  • (void)viewDidLoad { [super viewDidLoad];

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

self.quoteLabel = [self.quote objectAtIndex:1];

}

@end

2 Answers

you should add the dot "text" property, to be like this :

self.quoteLabel.text = [self.quote objectAtIndex:1];

because you code will make the label itself a string which will make the app crashes, you should change the text of the label instead

You want to assign something to the text of the UILabel, so you should use self.quoteLabel.text. Also, make sure you are calling objectAtIndex on self.quotes rather than self.quote.

See below:

self.quoteLabel.text = [self.quotes objectAtIndex:1];