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
Simon Sunde
1,639 PointsImplementing an Array
When i try to run my app in the simulater, and press down my button, i get an error message, see it here [ http://omatic.dk/ios-help.png ]
Please help, i have no clue what to do ?
My code is:
-
(IBAction)buttonPressed {
NSArray *predictions = [[NSArray alloc] initWithObjects:@"It is surdent",@"It is Decidensly so",@"All signs says YES", nil];
self.predictionLabel.text = [predictions objectAtIndex:3]; }
2 Answers
Holger Liesegang
50,595 PointsHi Simon, there doesn't exist an object at Index 3 in your NSArray predictions (therefore NSRangeException has been raised) because you start counting at index 0 and thus the last object is at index 2.
Simon Sunde
1,639 PointsHey Holger, thank you so much, i've got it now!