Reputation: 10108
I'm using AFNetworking
for my app.
I want to create a queue mechanism with different priority for each HTTP request
.
For that - I need to be able to create an HTTP Request
using AFNetowrking
but use it later.
The example for creating an HTTP request is:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://example.com/resources.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
This code will send the request immediately. How can I just create the request (method, parameters, url), but use it at a later time?
Upvotes: 1
Views: 3512
Reputation: 555
Check operationQueue of AFHTTPRequestOperationManager. If you suspend it before adding request, it will not run until you resume operation queue. For example:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager.operationQueue setSuspended:YES];
Upvotes: 4
Reputation: 10108
Turns out you need to create an AFHTTPRequestOperation instead of a manager.
Full article here: http://samwize.com/2012/10/25/simple-get-post-afnetworking/
Upvotes: -2