AFNetworking 3和Swift 2-无法转换值NSURLSessionDataTask

时间:2016-07-09 03:17:38

标签: swift2 afnetworking-3 nsurlsessiondatatask

当尝试从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的一部分。希望有人可以对此有所了解,并提前非常感谢你!

0 个答案:

没有答案