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



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