Created
December 3, 2018 08:38
-
-
Save gitCommitLit/0f898327743997c437bf2b5ab4effe07 to your computer and use it in GitHub Desktop.
[updateDisplay]AppDelegate.swift func
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
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