I have a login screen and when a button is pressed this code executes:
- (IBAction)btnLogin:(id)sender {
[username resignFirstResponder];
[password resignFirstResponder];
Auth *authRequest = [[Auth alloc] init];
NSURL *url = [[NSURL alloc] initWithScheme:@"http" host:APIHOST path:@"/authenticate"];
[authRequest setUrl:url];
[authRequest setUsername:[username text]];
[authRequest setPassword:[password text]];
[authRequest authenticate];
[self performSegueWithIdentifier:@"Login2Tab" sender:self];
}
This works well and the segue executes as expected (So I know the segue exists and its identified correctly in the storyboard). I however don't want to perform the segue until the connection has finished loading so this implementation file is my delegate for NSURLConnection and at the bottom I have (and the if/else on responseCode does work)..:
// Close the connection
- (void)connectionDidFinishLoading:(NSURLConnection*)connection {
if(responseCode == 200) {
[self performSegueWithIdentifier:@"Login2Tab" sender:self];
} else {
NSLog(@"Bad.. bad.. bad...");
}
NSLog(@"Connection Closed.");
}
(When I put the performSegueWithIdentifer in the connectionDidFinishLoading I comment out the performSegueWithIdentier from above...).
But now the app always crashes stating:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (LoginViewController: 0x7163640) has no segue with identifier 'Login2Tab''
Which is where I am stuck because it works when its not called from within the connectionDidFinishLoading...