I can't login to the app at first attempt but after trying 3 times then only I am able to login in the app

my codes are following :

  • (IBAction)done:(id)sender

{

[self setField:jidField forKey:kXMPPmyJID];

/// [self setField:passwordField forKey:kXMPPmyPassword];

[self setPass:passwordField forKey:kXMPPmyPassword];

  RootViewController *root = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];

[root initWithPassword:passwordField.text initWithUser:jidField.text];

 //[[ self appDelegate]  setupStream];

[ [ self appDelegate] xmppStreamDidConnect: [[self appDelegate] xmppStream]];

//[ [ self appDelegate] goOnline];

   [window setRootViewController:navigationController];

// [self.window setRootViewController:settingsViewController];

[window makeKeyAndVisible];

//[self presentViewController:root animated:YES completion:nil];

[self dismissViewControllerAnimated:YES completion:NULL];

}

Can anyone help me to login at first time?