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 trialSuzanne Dawson
472 PointsCrystal 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
16,502 PointsYour second array should be allocated and initialised for 'self.colors' (you wrote 'self.predications' twice).
Hope this helps
Suzanne Dawson
472 PointsThank you Sebastian! I did see that and change it, however, I am still having a myriad of issues.