如何使用 Alamofire 反映JSON词典中的数据,以执行验证以检查输入的密码对我的UI View Controller是否有效。我已经获得了从API中获取数据的成功结果,但是我不知道我的视图控制器如何从API中读取值以验证输入的密码。请帮助我。......
APIService
res.headers('x-auth', token)
ViewController
class APIService
{
let eventAPIKey: String
let eventBaseURL: URL?
//static let kEventID = "id"
init(APIKey: String)
{
self.eventAPIKey = APIKey
eventBaseURL = URL(string: BASE_URL)
}
func validatePasscode(passcode: String, completion: @escaping (Event?) -> Void)
{
if let passcodeURL = URL (string: "\(PASSCODE_CHECKER_URL)/\(passcode)") {
Alamofire.request(passcodeURL, method: .get).responseJSON { (response) in
switch response.result{
case .success:
if let passcodeJSON = response.result.value {
print(passcodeJSON)
completion(passcodeJSON as? Event)
}
case .failure(let error):
print("\(error)")
}
}
}
}
}