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!

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

Twitter login - Only if user have an account

Any ideas on how to only let user who already signed up to log in and the user who not signed up gets pushed to signup? I only want the user to be able to log in with twitter if the user already is signed up and is linked with a user.

This is my code now:

´´´

IBAction)twitterLogin:(id)sender { {

    {



        [PFTwitterUtils logInWithBlock:^(PFUser *user, NSError *error) {


         if (error) {


             [self dismissViewControllerAnimated:NO completion:nil];
             [self performSegueWithIdentifier:@"twitterSetup" sender:self];

             NSLog(@"Don't have an account.");
             return;
             UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@""
                                                                 message:@"In order to log in with Twitter you need to sign up a user first"
                                                                delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];


             [alertView show];
             [hud hide:YES];



            } else if (user){



                NSLog(@"User logged in with Twitter!");

                NSString *twitterScreenName = [PFTwitterUtils twitter].screenName;
                [[PFUser currentUser] setObject:twitterScreenName forKey:@"username"];
                [[PFUser currentUser] saveInBackground];

                [hud hide:YES];
                [self dismissViewControllerAnimated:YES completion:nil];
                [self.navigationController popToRootViewControllerAnimated:YES];



            }
        }];

    }
}

}

Thanks!

´´´