Padin215
Padin215

Reputation: 7484

AFNetworking and setting up request queue

I'm making a AFRequestionOperation call:

- (id)init {
    if (self = [super init]) {
        // Other code

        AFHTTPClient *client = [[AFHTTPClient alloc] init];
        [client registerHTTPOperationClass:[AFImageRequestOperation class]];
        [client.operationQueue setMaxConcurrentOperationCount:2];

        self.HTTPClient = client;
    }

    return self;
}

When I need to make the request:

AFHTTPRequestOperation *request = [self.HTTPClient HTTPRequestOperationWithRequest:urlRequest success:^(AFHTTPRequestOperation *operation, id responseObject) {
    // Code
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    // Code
}];

[self.HTTPClient enqueueHTTPRequestOperation:request];

When I check the queue:

DLog(@"queue: %@", self.HTTPClient.operationQueue);

it shows the queue as null.

it doesn't make any calls.

I can use:

[request start];

but pretty sure that isn't use the Queue.

Upvotes: 0

Views: 1293

Answers (1)

Felix
Felix

Reputation: 35394

You need to use the designated initializer of AFHTTPClient:

- (id)initWithBaseURL:(NSURL *)url;

Upvotes: 1

Related Questions