我正在使用Alamofire从Web API检索数据:
func getData(completionHandler: (responseObject: NSDictionary?) -> ()) -> () {
Alamofire.request(.GET, "http://example.com/api/resource/")
.validate()
.authenticate(user: user, password: password)
.responseJSON { (request, response, responseObject) in
switch responseObject {
case .Success:
print("Validation Successful")
completionHandler(responseObject: responseObject as? NSDictionary)
case .Failure(_, let error):
print(error)
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
getData { (str, error) in
if str != nil {
print(str)
} else {
print(error)
}
}
}
当我运行代码时,出现了一个错误,错误如下所示。
Command failed due to signal: Segmentation fault: 11
我不知道它出了什么问题,也不知道如何修复。 非常感谢您的任何建议。