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 Build a Self-Destructing Message iPhone App Using Parse.com as a Backend and Adding Users Signing Up New Users: Part 2 (PFUser)

I'm getting an Expected Identifier error and I can't pinpoint why.

Below is the code for my Ribbit app. After my UIAlerView, before the alertView show part, I'm getting an Expected Identifier error. I checked my code against the downloadable code in the class - and they look the same. The other problem is, the downloadable file doesn't run - it's laced with errors, too. So I have no examples of working code to check my code against. Does anyone know why I'm getting this Expected Identifier error? Thanks!

        else {

        PFUser *newUser = [PFUser user];
        newUser.username = username;
        newUser.password = password;
        newUser.email = email;

        [newUser signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
            if (error) {
                UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Sorry!" message:[error.userInfo objectForKey:@"error"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                [alertView show];
            }

            else {
                [self.navigationController popToRootViewControllerAnimated:YES];

            }
            }];
    }
}

Hey Levi, check the Markdown Cheatsheet to see how to post code on the forums. I've fixed it up for you.

1 Answer

Ravee Sundar
PLUS
Ravee Sundar
Courses Plus Student 1,975 Points

you have an extra "[" in your alertView creation. Try this

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:[error.userInfo objectForKey:@"error"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];