0

When using 'Custom Module', there are times when multiple asynchronous requests happen at the same time (handled by the same delegate) and there is a need to distinguish which request triggered the 'completedWithResult' callback.

Is there a way to provide a custom callback function for a particular request? If not, what would be the best way to distinguish between multiple requests inside the 'completedWithResult'callback?

ken
  • 3,897
  • 3
  • 22
  • 28

1 Answers1

1

You should use context

 [QBUsers logInWithUserLogin:@"injoitUser1" password:@"injoitUser1" delegate:self context:@"thisIsPoint1"];

 [QBUsers logInWithUserLogin:@"injoitUser1" password:@"injoitUser1" delegate:self context:@"thisIsPoint2"];

- (void)completedWithResult:(Result *)result context:(void *)contextInfo{
    if([result isKindOfClass:QBUUserLogInResult.class]){
        if(result.success){
            if([((NSString *)contextInfo) isEqualToString:@"thisIsPoint1"]){
                // do smthn
            }
        }
}
Rubycon
  • 18,156
  • 10
  • 49
  • 70