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

Implementing array error

Hey I'm doing the Implementing the array video and I have type the objects in my array. I have also typed the code to call whats at index 0, like in the video, but when I run it says succeeded, and I press the button it take me to the debug navigator and shows some code from Thread 1. I'm not sure what to do.

Well your app is crashing, can i see your code to help.

import "THViewController.h"

@interface THViewController ()

@end

@implementation THViewController

  • (void)viewDidLoad { [super viewDidLoad];

    self.predictions = [[NSArray alloc] initWithObjects: @"It is Certain", @"It is Decidely so", @"All signs say YES", @"The stars are not aligned", @"My reply is no", @"It is doubtful", @"Better not tell you no", @"Concentrate and ask again", @"Unable to answer now", nil];

    //[predictions objectAtIndex:0];

    // Do any additional setup after loading the view, typically from a nib. }

-(void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated];

CGRect frame = self.predictionLabel.frame;
self.predictionLabel.frame = CGRectMake(frame.origin.x, 200, frame.size.width,frame.size.height);

}

  • (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }

  • (IBAction)buttonPressed {

    int random = arc4random_uniform(self.predictions.count);

    self.predictionLabel = [self.predictions objectAtIndex:random]; //self.predictionLabel.text = @"YES"; } @end

2 Answers

Stone Preston
Stone Preston
42,016 Points

sounds like you may have set a breakpoint. try pressing command + y to disable breakpoints and try again. If that doesnt work, post the error information from the console

Wow so simple, and it works thanks