Skip to content

Instantly share code, notes, and snippets.

@TheSwiftyCoder
Created January 11, 2017 17:19
Show Gist options
  • Save TheSwiftyCoder/9985bab9fb9210c6ec92e64a186a92e5 to your computer and use it in GitHub Desktop.
Save TheSwiftyCoder/9985bab9fb9210c6ec92e64a186a92e5 to your computer and use it in GitHub Desktop.
Gives an example how to pull out JSON data using SwiftyJSON
let currentWeather = JSON(weatherData) // From the API call returned as [String: AnyObject]
let current = currentWeather["current"]
// Dispatch queue prevents app errors when calling the API data from a background thread
DispatchQueue.main.async {
self.friendlyUserMessageLabel.text = current["condition"]["text"].stringValue
self.windDirectionLabel.text = current["wind_dir"].stringValue
self.tempDayLabel.text = "\(current["temp_c"].stringValue)°"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment