我的API类中有这两种方法可以从API获取数据:
func authenticateUser(completionHandler: (responSEObject: String?,error: NSError?) -> ()) { makeAuthenticateUserCall(completionHandler) } func makeAuthenticateUserCall(completionHandler: (responSEObject: String?,error: NSError?) -> ()) { Alamofire.request(.GET,loginUrlString) .authenticate(user: "a",password: "b") .responseString { request,response,responseString,responseError in completionHandler(responSEObject: responseString as String!,error: responseError) } }
然后在另一个类中,我使用以下代码来访问数据:
API().authenticateUser{ (responSEObject,error) in println(responSEObject) }
代码正在运行,但我完全不理解.
> func authenticateUser具有参数completionHandler 原文链接:https://www.f2er.com/iOS/328034.html