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 Self-Destructing Message iPhone App Using Parse.com as a Backend and Adding Users Logging In and Logging Out

can someone help

  • (void)viewDidLoad { [super viewDidLoad];

    PFUser * currentUser = [PFUser currentUser]; if (currentUser==nil) { [self performSegueWithIdentifier:@"showLogin" sender:self]; }

}

3 Answers

Stone Preston
Stone Preston
42,016 Points

I 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

ohhh i put in the loginviewcontroller

Stone Preston
Stone Preston
42,016 Points

yeah it needs to go in MainViewController

thanks man

Stone Preston
Stone Preston
42,016 Points

no problem. glad i could help