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 Simple iPhone App (iOS7) Animating and Intercepting Events Image Based Animation

Alex Suarez
Alex Suarez
868 Points

Expected Identifier in Xcode 6.1

When I write the code under #pragma mark - Prediciton

 - (void) makePrediction {
[self.backgroundImageView.startAnimating];
self.predictionLabel.text = [self.crystalBall randomPrediction];

}

Xcode 6.1 gives me a "build failed" message, and a error "! Expected Identifier" on the startAnimating. When I read the documentation it says starAnimating is written in the form

 - (void) startAnimating 

So, what am I doing wrong??? it works for Amit!?

1 Answer

Michael Hulet
Michael Hulet
47,912 Points

What you're doing wrong is you're still using dot notation in the first line of code you gave. Your makePrediction method should look something like this:

 - (void) makePrediction {
    //Notice how there's no period between "self.backgroundImageView" and "startAnimating"
    [self.backgroundImageView startAnimating];
    self.predictionLabel.text = [self.crystalBall randomPrediction];
}

In Objective-C you call methods between square brackets by writing the object you want to call the method on first, then a space, then the method after that, like this:

[object method];