Search code examples
iosiphoneios7xcode5afnetworking-2

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


In AFNetworking 2.x version for Xcode 5, I am Continuously Receiving the warning for this Method for this

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

the self.request is Incompatible pointer types sending 'NSURLRequest *' to parameter of type '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;
}

is anybody get Solved this issue(warning) ..


Solution

  • The problem is that [self class] returns a Class object of a type that is not determined. The compiler is matching the -initWithRequest: method with that from MapKit. This can be fixed by changing the code to:

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