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 trialMeek D
3,457 Pointscan someone help
-
(void)viewDidLoad { [super viewDidLoad];
PFUser * currentUser = [PFUser currentUser]; if (currentUser==nil) { [self performSegueWithIdentifier:@"showLogin" sender:self]; }
}
3 Answers
Stone Preston
42,016 PointsI tried your code and it worked just fine, make sure you are implementing this code in mainViewController.m though
#import "MainViewController.h"
#import "LoginViewController.h"
#import <Parse/Parse.h>
@implementation MainViewController
- (void)viewDidLoad {
[super viewDidLoad];
PFUser * currentUser = [PFUser currentUser];
if (currentUser==nil) {
[self performSegueWithIdentifier:@"showLogin" sender:self];
}
}
- (IBAction)logOut:(id)sender {
[self performSegueWithIdentifier:@"showLogin" sender:self];
}
@end
Meek D
3,457 Pointsohhh i put in the loginviewcontroller
Stone Preston
42,016 Pointsyeah it needs to go in MainViewController
Meek D
3,457 Pointsthanks man
Stone Preston
42,016 Pointsno problem. glad i could help