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 Build a Playlist Browser with Objective-C Working With Multiple View Controllers UIButton Recap

UIButton Recap Challenge 1 of 2; keep getting syntax error, what gives!?

Hi no matter what I do this challenge keeps throwing back a compiler syntax error. I believe this may be a bug as I don't actually receive an error in Xcode itself. I tried writing the solution in Obj-C and Swift to no avail.

Challenge Task 1 of 2: Let’s assume we have an IBOutlet of type UIButton, named timerButton, as a property in our view controller header file. In the implementation file, set the title of the button to β€œStart!” for the state configuration UIControlStateNormal. Hint: Check out the UIButton class reference in the documentation.

ViewController.h
#import "UIViewController.h"
#import "UIButton.h"

@interface ViewController : UIViewController

@property (strong, nonatomic) IBOutlet UIButton *timerButton;

@end
ViewController.m
#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    UIColor *redColor = [UIColor redColor];

    // Enter your code below!
    [self.timerButton setTitle:@"Start!" forState:UIControlStateNormal];


}


@end

1 Answer

Rebekah Shaw
Rebekah Shaw
18,687 Points
 [self.timerButton setTitle:@"Start!" forState:UIControlStateNormal];

That's what I did and it worked, not sure what is going on for you.

At the time that this was posted there was a bug with the compiler for Objective-C. Challenge was correct :)