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

Crystal Ball extra credit issue

on the Interface page I have

@interface SDViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *predictionLabel;
@property (strong, nonatomic) NSArray *predictions;
@property (strong, nonatomic) IBOutlet UIColor *color;
@property (strong, nonatomic) NSArray *colors;
For the implementation page I have
- (void)viewDidLoad
{
    [super viewDidLoad];

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

    self.predictions = [[NSArray alloc] initWithObjects:
                       @"red",
                       @"green",
                       @"blue",nil];


}


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

- (IBAction)buttonPressed {
    int random = arc4random_uniform(self.predictions.count);
    self.predictionLabel.text = [self.predictions objectAtIndex:random];
    self.color = [self.colors objectAtIndex:random];

}

What am I doing wrong. I don't have any stop signs. I do have an empty circle in the gutter though on the VC.h page

2 Answers

Sebastien Thomas
Sebastien Thomas
16,502 Points

Your second array should be allocated and initialised for 'self.colors' (you wrote 'self.predications' twice).

Hope this helps

Thank you Sebastian! I did see that and change it, however, I am still having a myriad of issues.