When following the AFNetworking example to upload a form:
NSURL *url = [NSURL URLWithString:@"https://www.example.com/"];
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:url];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
keyField.text, @"key",
valField.text, @"val",
nil];
NSData *imageData = UIImagePNGRepresentation(image);
NSURLRequest *request = [client multipartFormRequestWithMethod:@"POST"
path:@"/upload"
parameters:params
constructingBodyWithBlock: ^(id <AFMultipartFormData> formData) {
[formData appendPartWithFileData:imageData
mimeType:@"image/png"
name:@"avatar"];
}];
Compilation returns error:
ARC Issue: No known instance method for selector 'appendPartWithFileData:mimeType:name:'
How can I fix it?
It’s a bit strange that the compiler considers this an “ARC issue”. IMHO the
AFMultipartFormDataprotocol doesn’t contain a method calledappendPartWithFileData:mimeType:name:. Take a look at the documentation, maybe the protocol was refactored and the method signature change a bit. I’m not sure where doesAFMultipartFormDatacome from, but a short search gave me these docs that suggest you might have success withappendPartWithFileData:name:fileName:mimeType:.