I have a method that needs calls another method which will have a callback made, I want my first method to wait until that callback is made to proceed. I am setting a flag on my callback, but I need the method to pick up the change.
I've tried a while loop but it takes up the main thread, dispatching it in the background also doesn't seem to work.
Seems like a simple task but I can't figure this out..
What I want is the while loop to exit after the variable is changed by my delegate method.
-(BOOL) keepAlive{
NSString *name = nil;
NSString *pw = nil;
KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"login" accessGroup:nil];
name = [wrapper objectForKey:(__bridge id)kSecAttrAccount];
pw = [wrapper objectForKey:(__bridge id)kSecValueData];
//Call authentication
self.loginType = KeepAlive;
[self.loginManager authenticate:name andPass:pw];
self.loginStatus = loginPending;
while (1) {
if(self.loginStatus == loginSuccess){
return true;
}else{
return false;
}
}
return false;
}