当尝试从AFHTTPSessionManager访问GET函数时,我收到错误,输入操作:
"无法转换类型'(NSURLSessionDataTask!,AnyObject!)的值 - >虚空'预期参数类型'((NSURLSessionDataTask,AnyObject?) - > Void)?'"
return self.GET("search", parameters: parameters, success: {(operation:NSURLSessionDataTask!, response:AnyObject!) -> Void in
let dictionaries = response["businesses"] as? [NSDictionary]
if dictionaries != nil {
completion(Business.businesses(array: dictionaries!), nil)
self.appDelegate.businessesLoaded = true
}
}, failure: { (operation: AFHTTPSessionManager?, error: NSError!) -> Void in
completion(nil, error)
})!
AFHTTPSessionManager.m GET功能:
- (NSURLSessionDataTask *)GET:(NSString *)URLString
parameters:(id)parameters
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
{
return [self GET:URLString parameters:parameters progress:nil success:success failure:failure];
}
这一切都与AFHTTPRequestOperation一起使用,AFHTTPRequestOperation不再是已弃用的NSURLConnection的AFNetworking 3的一部分。希望有人可以对此有所了解,并提前非常感谢你!