tristanhimmelman / AlamofireObjectMapper

An Alamofire extension which converts JSON response data into swift objects using ObjectMapper
MIT License
2.66k stars 476 forks source link

Generic type 'DataResponse' specialized with too few type parameters (got 1, but expected 2) #285

Closed deezaster closed 4 years ago

deezaster commented 4 years ago

Versions i use:

AlamofireObjectMapper 6.1.0 ObjectMapper 3.5.1 Alamofire 5.0.0-rc.2

Problem with .responseArray:

      AF.request(getUrlAPI(.GetAllMembers, apiVersion: "v4"), parameters: self.apiParams)

         .responseArray{ (response: DataResponse<[MemberJSON]>) in    

Error:

image

aehlke commented 4 years ago

Did you resolve this?

clasters commented 4 years ago

i have this problem too.

ozgur commented 4 years ago

This has been fixed in https://github.com/tristanhimmelman/AlamofireObjectMapper/pull/288

freakdragon commented 4 years ago

I just changed the type DataResponse to AFDataResponse.

What I had: responseData(completionHandler: { (dataResponse: DataResponse<Data>) in }

What I have now: responseData(completionHandler: { (dataResponse: AFDataResponse<Data>) in }

I've got error when updated Alamofire from 5.0.0-beta.7 to 5.0.0-rc.2

You can look here https://github.com/tristanhimmelman/AlamofireObjectMapper/pull/284

tristanhimmelman commented 4 years ago

Closing as the PR to fix this has been merged and released

suryakantkachhi commented 4 years ago

Hi

I'm still getting this error with below pods, i tried all mentioned Git master but nothing working.

Getting this error in XCODE11 with swift 5.

When i use AFDataResponse instead of DataResponse then issue go away. i don't whether its the correct approach to resolve the same ?

Please Help me to get out of it. thanks

pod 'Alamofire', '~> 5.0.0-rc.2' pod 'ObjectMapper', '~> 3.4'

pod 'AlamofireObjectMapper', :git => 'https://github.com/tristanhimmelman/AlamofireObjectMapper.git', :branch => 'master'

pod 'AlamofireObjectMapper', :git => 'https://github.com/RomanPodymov/AlamofireObjectMapper.git', :branch => 'master'

pod 'AlamofireObjectMapper', :git => 'https://github.com/ozgur/AlamofireObjectMapper.git', :branch => 'master'

pod 'AlamofireObjectMapper', '~> 6.2.0'

pod 'AlamofireObjectMapper', '~> 5.2'

pod 'Alamofire', '~> 4.0.0'

Screenshot 2019-11-03 at 7 16 23 PM

freakdragon commented 4 years ago

@suryakantkachhi , did you try to change (response: DataResponse<LoginDSModel>) to (response: AFDataResponse<LoginDSModel>)?

dangquockhanh commented 4 years ago

_ = AF.request(URL, method: .get).responseObject { (response: AFDataResponse) in

        let mappedObject = response.value
            print(mappedObject?.location)
dangquockhanh commented 4 years ago

AlamofireObjectMapper-6.2.0.zip see here

DimitrisBovasianos commented 4 years ago

DataResponse<Any,AFError>

haroldogtf commented 4 years ago

I am getting the same. What should I do?

DimitrisBovasianos commented 4 years ago

This is how i made it to work.

Response is a struct to parse the response.

struct Response: Codable {
    let test : String

}
static func getApiRequest(url:String, parameters:Dictionary<String, Any>,completion:@escaping (AFResult<Response>)->Void) {
        let headers = configureCurrentSession()
        AF.request(url,method: .get, encoding : JSONEncoding.default,headers:headers).responseDecodable { (response: AFDataResponse<Response>) in
            completion(response.result)
            return

        }

    }
DonPex commented 4 years ago

Please @tristanhimmelman, update the README.md inserting the latest versions for Carthage and Cocoa. I spent hours trying to solve the incompatibility issue of AFDataResponse<T> as parameter of responseObject {...}.

partho-maple commented 4 years ago

I tried all of the mentioned approaches but nothing worked for me.