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

Crystal Ball extra credit

For the adding UIcolor array extra credit assignment, I have now managed to get a successful build without any errors, but when I press the predict button the color of the text does not change. What am I missing? Here is what I have: Interface page#import <UIKit/UIKit.h>

@interface SDViewController : UIViewController @property (strong, nonatomic) IBOutlet UILabel *predictionLabel; @property (strong, nonatomic) NSArray *predictions; @property (strong, nonatomic) NSArray *colorsArray;

  • (IBAction)buttonPressed;

@end Implementation page#import <UIKit/UIKit.h>

@interface SDViewController : UIViewController @property (strong, nonatomic) IBOutlet UILabel *predictionLabel; @property (strong, nonatomic) NSArray *predictions; @property (strong, nonatomic) NSArray *colorsArray;

  • (IBAction)buttonPressed;

@end@implementation SDViewController

  • (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.colorsArray = [[NSArray alloc] initWithObjects: @"Red", @"Blue", @"Green", @"Purple", 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];

}

@end

1 Answer

Suzanne, If you want to get the "button text" color to change you can do this in the standard editor. Select the button change the State Config from Default to selected or highlighted then change the Text color.

Hi Aaron, Can't believe life took me away from my project for over a week! Thank you for getting back to me. I believe the assignment requires we make the text color change randomly along with the actual text object every time we press the predict button. Can't seem to figure this out. Do I ad another array with 4 or 5 different colors under each text object? Afraid I don't know where to find change the State Config is. Is the Main Storyboard the standard editor?