dimanche 1 février 2015

Are these related "performSelectorInBackground" and "performSelectorOnMainThread"?How does it exactly works? [duplicate]


Its in login process



if(![[_emailText text] isEqualToString:@""] &&![[_passwordText text] isEqualToString:@""]){
[self performSelectorInBackground:@selector(loginInbackground) withObject:nil];
// Hide Keyboards
[_emailText resignFirstResponder];
[_passwordText resignFirstResponder];

// Show the logging in screen
[_loggingInView setHidden:false];
}


They have used performSelectorInBackground,and after this



-(void)loginInbackground{
// Add the username and password to the keychain
keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"login" accessGroup:nil];
[keychain setObject:@"loginData" forKey:(__bridge id)kSecAttrService];
[keychain setObject:[[_emailText text] lowercaseString] forKey:(__bridge id)kSecAttrAccount];
[keychain setObject:[_passwordText text] forKey:(__bridge id)kSecValueData];
keychain = nil;

if([self loginwithuser:[_emailText text] andPassword:[_passwordText text]]){
[self performSelectorOnMainThread:@selector(loginCompletewithbool:) withObject:[NSNumber numberWithInt:1] waitUntilDone:TRUE] ;
}else{
[self performSelectorOnMainThread:@selector(loginCompletewithbool:) withObject:[NSNumber numberWithInt:0] waitUntilDone:TRUE] ;
}


What does performSelectorOnMainThread do?




Aucun commentaire:

Enregistrer un commentaire