There is a statement called -retry: that takes a count parameter. If you apply this operator to a signal, and this signal returns an error, it will re-subscribe to the signal (up to the specified number of times) when an error is received. So you need a signal that asks for user credentials when subscribing.
@weakify(self); RACSignal *requestCredentials = [RACSignal defer:^{ @strongify(self); // (Prompt the user for credentials.) if (successful) { self.cachedCredentials = credentials; return [self authenticate:credentials]; } else { return [RACSignal error:[[MyError alloc] init]]; } }]; // We try to authenticate using the cached credentials (the // `-authenticate:` method returns a signal that attempts // authentication when it is subscribed to). If the initial // attempt to authenticate fails, we try 3 times to get the // user to enter the correct credentials. return [[self authenticate:self.cachedCredentials] catchTo:[requestCredentials retry:3]];
erikprice
source share