-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I use retry/polling in ObjC? #1043
Comments
- (void)attempt:(int)maximumRetryCount, delay:(NSTimeInterval)delay provider:(PMKPromise* (^)()) {
__block int attempts = 0;
PMKPromise *(^attempt)() = ^{
attempts++;
return provide().catch(^(id error) {
if (attempts >= maximmumRetryCount) @throw error;
return PMKAfter(delay).then(attempt);
})
};
return attempt()
} My objc is rusty so may not compile. |
6 is the same as 4 for objc. No need to upgrade, but we don't typically back port fixes to v4. |
Wow, that is some serious block syntax action going on. I got it to compile with these modifications:
Does this look right? I got these warnings: On the empty () in the method signature On EDIT: Also, how do I call the attempt method correctly with this method:
Thanks so much for your help and your work on such an awesome library! |
|
Like you could probably use a selector rather than a block. It's been a long time since I did any objc. |
Perfect! Again, thank you! |
How would I write this
attempt
method from the docs in ObjC?I have read the comments in #350 (comment) about
catch
behaving the same asrecover
, but I'm struggling with translating it into ObjC.Thanks!
PromiseKit 4.5.2 (mainly because I'm not sure about changes to Obj-C support in later versions)
Cocoapods 1.5.3
The text was updated successfully, but these errors were encountered: