我开始使用 AFNetworking 来替换不幸失效的 ASIHTTPRequest。人们似乎喜欢这个新的“AFNetworking”,但它没有构建在我的项目中,我不明白为什么。Class class = NSClassFromString(className);我在HTTPRequestOperationWithRequest:success:failure文件中开始遇到构建错误AFHTTPClient.m。
错误是“匿名类的声明必须是定义”,我已经问过谷歌但没有得到任何结果。帮助?
语境:
- (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];
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:根据下面的答案解决。补丁文件在这里。
编辑 2:这些更改已被纳入最新的 AFNetworking 中,因此将来发现此内容的任何人:只需下载新版本即可。还有,未来怎么样?你好未来。
小智 5
我能够通过将变量“class”重命名为其他名称来解决编译器错误。不幸的是,我无法弄清楚为什么会遇到这个问题。这里有一个线索:当我将 AFNetworking 添加到一个具有未知编译器标志的大型现有项目时,就发生了这种情况。当我将 AFNetworking 添加到一个新项目中时,我根本没有遇到这个问题。
| 归档时间: |
|
| 查看次数: |
6571 次 |
| 最近记录: |