Skip to content

Instantly share code, notes, and snippets.

@iannase
Last active March 28, 2020 15:54
Show Gist options
  • Save iannase/32a627a16d63a24ade8ea14b913035e8 to your computer and use it in GitHub Desktop.
Save iannase/32a627a16d63a24ade8ea14b913035e8 to your computer and use it in GitHub Desktop.
How to make an API call on JSON data that has an array.
Alamofire.request(apiURL).responseJSON { (response) in
if response.result.isSuccess {
guard let data = response.result.value as? [String: Any] else { return }
guard let results = data["results"] as? NSArray else { return }
for result in results {
if let result = result as? [String: Any] {
if let elevation = result["elevation"] as? Double {
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment