AFNetworking 2.0 iOS 7 Copy with zone warning in AFHTTPRequestOperation.h file

In AFNetworking 2.x for Xcode 5, I constantly get a warning for this method for this

AFHTTPRequestOperation *operation = [[[self class] allocWithZone:zone] initWithRequest:self.request];

self.request- these are incompatible pointer types that send 'NSURLRequest *'to the type parameter'MKLocalSearchRequest *'

#pragma mark - NSCopying

- (id)copyWithZone:(NSZone *)zone {
    AFHTTPRequestOperation *operation = [[[self class] allocWithZone:zone] initWithRequest:self.request];

    operation.responseSerializer = [self.responseSerializer copyWithZone:zone];
    operation.completionQueue = self.completionQueue;
    operation.completionGroup = self.completionGroup;

    return operation;
}

Someone will get this problem (warning).

+3
source share
1 answer

The problem is that it [self class]returns an object of Classtype that is not defined. The compiler maps the method -initWithRequest:to the MapKit method. This can be fixed by changing the code to:

AFHTTPRequestOperation *operation = [(AFHTTPRequestOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request];
+3
source

All Articles