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

Jamie Baker
Jamie Baker
5,703 Points

challenge 3/4 of Signing Up New users part 2, I am getting an error in my code and am lost as to why!

QUESTION: Now let's use the 'signUpInBackgroundWithBlock' method to sign up this new user. Send this message to the newUser variable. For the block parameter, copy and paste the following empty block: ^(BOOL succeeded, NSError *error) {}

ANSWER: [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]; }];

1 Answer

Stone Preston
Stone Preston
42,016 Points

The task states: or the block parameter, copy and paste the following empty block: ^(BOOL succeeded, NSError *error) {} so the block needs to be empty, you put code inside the block. remove it so that its empty:

- (IBAction)signup:(id)sender {

    self.username = self.usernameField.text;
    self.password = self.passwordField.text;

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

    [newUser signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {

    }];
}