Skip to content

Instantly share code, notes, and snippets.

@gitCommitLit
Created December 3, 2018 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gitCommitLit/0f898327743997c437bf2b5ab4effe07 to your computer and use it in GitHub Desktop.
Save gitCommitLit/0f898327743997c437bf2b5ab4effe07 to your computer and use it in GitHub Desktop.
[updateDisplay]AppDelegate.swift func
func updateDisplay() {
guard let feed = feed else { return }
var text = "Error"
switch displayMode {
case 0:
// summary text
if let summary = feed["currently"]["summary"].string {
text = summary
}
case 1:
// Show current temperature
if let temperature = feed["currently"]["temperature"].int {
text = "\(temperature)°"
}
case 2:
// Show chance of rain
if let rain = feed["currently"]["precipProbability"].double {
text = "Rain: \(rain * 100)%"
}
case 3:
// Show cloud cover
if let cloud = feed["currently"]["cloudCover"].double {
text = "Cloud: \(cloud * 100)%"
}
default:
// This should not be reached
break
}
statusItem.button?.title = text
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment