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 with Objective-C Creating a Data Model Using a Data Collection

Genevieve Tan
Genevieve Tan
4,257 Points

How do we use objectAtIndex?

I typed

self.factsCopy = [ self.facts objectAtindex : (2)facts ];

I want to allocate the 3rd fact in facts to an NSArray called factsCopy.

How do i do it with objectAtIndex? Is my format correct ?

Caleb Kleveter
Caleb Kleveter
Treehouse Moderator 37,862 Points

So in the video we see the code below:

self.funFactLabel.text = [self.facts objectAtIndex:1];

So I think you want:

self.factsCopy.text = [self.facts objectAtIndex:2]

Hope this helps!