I am implementing a logout button in my project. I attached it by using the touch up inside event. When logout clicked, the user is redirected to login view controller but for some strange reason the application dies after a few seconds with the following error. Thread 1: signal SIGABRT.
Logout clicked: (all this method does is erasing the username and redirecting to "Login" view controller)
-(IBAction)logout {
[[NSUserDefaults standardUserDefaults] setObject:nil forKey:@"User"];
[self dismissViewControllerAnimated:NO completion:nil];
UIViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"Login"];
[self presentViewController:vc animated:NO completion:nil];
}
Login page has nothing when it loads.
Your signature for logout is all wrong. You should change the message line to:
You can ignore sender if you like. Your touch up inside is expecting to send a message to a method which has a parameter, and yours doesn't. That's why you're crashing.