Created
January 11, 2017 17:19
-
-
Save TheSwiftyCoder/9985bab9fb9210c6ec92e64a186a92e5 to your computer and use it in GitHub Desktop.
Gives an example how to pull out JSON data using SwiftyJSON
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
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