我在使用 Xcode 6.2 升级到 Xcode 7.0.1 后收到此错误消息。
/Users/ZERO/Documents/Xcode/XXXXX/Controllers/LoginViewController.swift:75:35: Cannot invoke initializer for type 'JSON' with an argument list of type '(Response)'
我的代码。
Alamofire.request(.POST , "http://192.168.1.124/wsesb.asmx/WSIniLogin", parameters: ["device_id": UIDevice.currentDevice().identifierForVendor!.UUIDString,"acc_token":acc_token])
.responseJSON { response in
if response.result.isSuccess {
var jsonObj = JSON(response) //error here
if(jsonObj[0]["Status"] == "SUCCESS"){//error here
if(jsonObj[0]["Data"][0]["Status"] == "SUCCESS"){ //error here
}
}
}
}
我的播客文件设置:
pod 'Alamofire', '~> 3.0'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
最佳答案
response
是 Response
类型的 Struct
。如果您需要从中获取 JSON,请执行以下操作:
if response.result.isSuccess {
var jsonObj = JSON(response.result.value)
...
}
关于ios - Swift - 无法使用类型为 'JSON' 的参数列表调用类型为 '(Response<AnyObject, NSError>)' 的初始值设定项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33430917/