jeudi 23 mars 2017

Cannot convert value of type [[EVObject]?] to expected argument type [_]

I am using Promise Kit for swift 3.0 and I am trying to fulfill my asynchronous network call with the

response.result.value

So I can use it in my ViewController function:

FeedbackServices.getFeedbackSubjects().then { (FeedbackSubject) -> Void in
            print(FeedbackSubject.count)
        }.catch { (error) in
            print(error.localizedDescription)
        }

This is my network layer:

protocol NetworkService
{
    static func GET<T:EVObject>(URL: String, parameters: [String: AnyObject]?, headers: [String: String]?) -> Promise<T>
    static func GET<T:EVObject>(URL: String, parameters: [String: AnyObject]?, headers: [String: String]?) -> Promise<[T]>

}

extension NetworkService
{

    static func GET<T:EVObject>(URL: String,
                    parameters: [String: AnyObject]? = nil,
                    headers: [String: String]? = nil) -> Promise<[T]>
    {

        return Promise { fullFill, reject in

            Alamofire.request(URL,
                              method: .get,
                              parameters: parameters,
                              encoding: URLEncoding.default,
                              headers: headers).responseArray(completionHandler: { response in

                        if (response.result.isSuccess) {

                            fullFill([response.result.value])

                        }else{
                            reject(response.result.error!)
                        }
                  })
            }
    }

When I try to build the project I get the following error:

enter image description here

I am stuck for a few hours now at work and I don't get it working. For any additional information please do not hesitate to ask me!.





Aucun commentaire:

Enregistrer un commentaire