ios – 了解swift Alamofire completionHandler

前端之家收集整理的这篇文章主要介绍了ios – 了解swift Alamofire completionHandler前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的API类中有这两种方法可以从API获取数据:
  1. func authenticateUser(completionHandler: (responSEObject: String?,error: NSError?) -> ()) {
  2. makeAuthenticateUserCall(completionHandler)
  3. }
  4.  
  5. func makeAuthenticateUserCall(completionHandler: (responSEObject: String?,error: NSError?) -> ()) {
  6. Alamofire.request(.GET,loginUrlString)
  7. .authenticate(user: "a",password: "b")
  8. .responseString { request,response,responseString,responseError in
  9. completionHandler(responSEObject: responseString as String!,error: responseError)
  10. }
  11. }

然后在另一个类中,我使用以下代码来访问数据:

  1. API().authenticateUser{ (responSEObject,error) in
  2. println(responSEObject)
  3. }

代码正在运行,但我完全不理解.

> func authenticateUser具有参数completionHandler

猜你在找的iOS相关文章