Reputation: 2923
I use the AFNetworking
framework and need to implement this logic to my web requests:
I see that AFHTTPRequestOperation
is a NSOperation
subclass, so I can write my own request manager but as I see there is AFHTTPRequestOperationManager
in the framework. I only found that I can make a concurrency queue here so my requests will be executed one after another. Can I get the described behavior with AFHTTPRequestOperationManager
? Thanks!
Upvotes: 0
Views: 343
Reputation: 7948
I will put this as an answer as well. So the idea is to do the following:
-create property for AFNetworkingOperation:
@property AFHTTPRequestOperation *post;
-in your initializer:
self.post = nil;
-in your function where you call request:
if(self.post){
[post cancel];
}
-you need to assign self.post later:
self.post = [manager POST:nil parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.post = nil;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// error handling.
}];
Upvotes: 1