Reputation: 4243
I am starting up with AFNetworking to replace the sadly-defunct ASIHTTPRequest. People seem to love this new "AFNetworking" but it doesn't build in my project and I can't figure out why. I'm getting build errors starting on Class class = NSClassFromString(className);
in HTTPRequestOperationWithRequest:success:failure
in the file AFHTTPClient.m
.
The error is "Declaration of anonymous class must be a definition" and I have asked teh google but not gotten anything. Help?
Context:
- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
AFHTTPRequestOperation *operation = nil;
NSString *className = nil;
NSEnumerator *enumerator = [self.registeredHTTPOperationClassNames reverseObjectEnumerator];
while (!operation && (className = [enumerator nextObject])) {
Class class = NSClassFromString(className);
if (class && [class canProcessRequest:urlRequest]) {
operation = [[(AFHTTPRequestOperation *)[class alloc] initWithRequest:urlRequest] autorelease];
}
}
EDIT: Solved per answer below. Patch file here.
EDIT 2: These changes have been pulled into the newest AFNetworking, so anyone finding this in the future: Just download a fresh version and you're all set. Also, how's the future? Hello future.
Upvotes: 0
Views: 6937
Reputation: 66
I was able to get around the compiler error by renaming the variable "class" to something else. Unfortunately, I was not able to figure out why I was getting the problem. Here's a clue: it happened to me when I added AFNetworking to a big existing project with unknown compiler flags. When I added AFNetworking to a fresh new project, I didn't hit the problem at all.
Upvotes: 5