Skip to content

Instantly share code, notes, and snippets.

@shawn-kb
Created February 1, 2016 17:48
Show Gist options
  • Save shawn-kb/261a8180171ea0d22373 to your computer and use it in GitHub Desktop.
Save shawn-kb/261a8180171ea0d22373 to your computer and use it in GitHub Desktop.
Alamofire.request(.GET, url, parameters: ["id": site.pressureSensorID])
.responseJSON { response in
//print(response.result) // result of response serialization
// handle network problem
switch response.result {
case .Success(_):
print("success code back from api server for sites request")
case .Failure(_):
let alertView = UIAlertController(title: "Connect Error", message: "Network error, please try again", preferredStyle: .Alert)
let alertAction = UIAlertAction(title: "OK", style: .Default) { _ in
}
alertView.addAction(alertAction)
self.presentViewController(alertView, animated: true) {}
}
if let jsonResult = response.result.value {
let arrayOfJSONDataPlots = JSON(jsonResult)
var arrayOfPlotPoints: [(Int, Double)]
for (key, item) in arrayOfJSONDataPlots {
print("key is \(key) and item is \(item)")
arrayOfPlotPoints.append((item[1], item[0]))
}
}
else {
print("JSON data is nil.")
}
} // end of json sites request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment