Skip to content

Instantly share code, notes, and snippets.

@betty-godier
Last active September 13, 2022 11:26
Show Gist options
  • Save betty-godier/06f0a5912088190e8190b2714350a9bb to your computer and use it in GitHub Desktop.
Save betty-godier/06f0a5912088190e8190b2714350a9bb to your computer and use it in GitHub Desktop.
Creation fund loadWeather, make a new task, create let location, let weather
import CoreLocation
import SwiftUI
import WeatherKit
struct ContentView: View {
private var currentSymbol: String?
private var conditions: String?
var body: some View {
ScrollView {
VStack {
if let currentSymbol {
Image(systemName: currentSymbol)
.font(.system(size: 200, weight: .light))
}
if let conditions {
Text(conditions)
.font(.title)
}
}
.frame(maxWidth: .infinity)
}
}
func loadWeather() {
Task {
let location = CLLocation(latitude: 36.3932, longitude: 25.4615)
let weather = try await WeatherService.shared.weather(for: location)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment