Created
February 1, 2016 17:48
-
-
Save shawn-kb/261a8180171ea0d22373 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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