2016-09-14 56 views
2

最近我已將我的xcode更新至版本8.0和Alamofire 4.0。在那之後我得到Use of undeclared type 'Response'此代碼:使用未聲明的類型「響應」錯誤

func getDate(completion: (Response<AnyObject,NSError>) -> Void){ 
    Alamofire.request(.GET, "http://www.example.ir/api/utiliti/example" ,parameters:nil) 
     .responseJSON{ response in 
      completion(response) 
    } 
} 

回答

5

問題上alamofire github上張貼問題

Use of undeclared type 'Response' error

使用此代碼

public enum Response { 
    case Failed(error : String) 
    case Success(data : Any) 
} 

func getDate(completion: @escaping (Response) -> Void){ 
    Alamofire.request("www.example.com/api", method: .get ,parameters:nil) 
      .responseJSON{ response in 
       switch response.result{ 
       case .failure(let error): 
       case .success(let value): 
       } 
     } 
} 
+2

後解決了這個不回答題。當你在github上發佈問題時神奇地解決了問題? –

+0

你說得對。文章編輯@OğuzSezer –

+0

你改變了什麼迴應? –