2017-08-15 34 views
0

Api響應只有布爾類似「true」或「false」,Alamofire responseObject無法使用。 我正在使用AlamofireObjectMapper 4.0和Swift 3.0Alamofire responseObject不能用於Bool響應

你能建議我該怎麼做?

一樣,目前我打電話API:

Alamofire.request(API_URL, method: .post, parameters: nil, encoding: JSONEncoding.default, headers : headers).responseObject{ (response: DataResponse<TestDto>) in 

     switch(response.result) { 
     case .success(_): 
      success(response.result.value!) 
      break 

     case .failure(_): 
      failure(response.result.error!) 
      break 
     } 
    } 

API響應僅是真的還是假的。

+0

得到使用它Alamofire.request(API_URL,方法:.POST,參數:無,編碼:JSONEncoding.default,標題:標題).responseJSON {(反應:任何)在 print(response) } – user2485755

回答

0

使用responseJSON如下,

Alamofire.request(API_URL, method: .post, parameters: nil, encoding: JSONEncoding.default, headers : headers).responseJSON{ (response: Any) in print(response) } 
相關問題