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

Justin Shulman
Justin Shulman
2,903 Points

What am i doing wrong? Its killing me!

Now it's time to display a quote from our 'quotes' array in the 'quoteLabel'. Assign the second item from the 'quotes' array to the text property of the 'quoteLabel'. Hint: use the 'objectAtIndex' method.

import "THViewController.h"

@implementation THViewController

  • (void)viewDidLoad { [super viewDidLoad];

    self.quotes = @[@"Life is simple, not easy", @"Winners never quit", @"Quitters never win"];

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



2 Answers

Stone Preston
Stone Preston
42,016 Points

ahh you initialized the array with the wrong strings. you used

@"Life is simple, not easy", @"Winners never quit", @"Quitters never win"

when you need to use

@"Haters gonna hate", @"Life is simple, not easy", @"Winners never quit, quitters never win"

the challenge engine let you pass with the incorrect strings for the second task (so the second object was @"Winners never quit..." and it was expecting the string to be @"Life is simple not easy" for the third task, which it wasnt. so fix the strings and it should work. also it does say to alloc and init the array (you used a NSArray literal, but it should work either way)

Justin Shulman
Justin Shulman
2,903 Points

Urrr always miss something in the details. Thanks!