Search code examples
iosrestkit

RESTKIT : How to abort unfinished network calls if new request is sent


Is there any way to abort all unfinished network calls which haven't returned responses yet when new network request is called?

Currently all request are getting added in NSOperationQueue. So I want to have one request at a time.


Solution

  • Using the object manager, call cancelAllObjectRequestOperationsWithMethod:matchingPathPattern: - though this does mean you need to know which patterns you want to cancel (or all potential patterns).

    Alternatively you can get all of the operations on the queue and cancel them...

    Usually you would only cancel one request when a new one is made so the pattern option suffices.