2016-09-14 58 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

你改变了什么回应? –