大多数浏览器和
Developer App 均支持流媒体播放。
-
为当日天气提供更多参考
充分发挥 WeatherKit 的强大功能来获取详细的天气预报数据,例如不同类型的降水量、不同海拔的云层覆盖情况,或者最大风速。探索如何按照一天的不同时段提供天气概况,并突出显示气温或降水方面即将出现的重要变化。了解如何通过我们的 Historical Comparisons 数据集将当前天气与过往天气进行比较,并深入了解全球任何地方的历史天气数据。我们还将探索如何使用 Swift 和 REST API 更快地实现所有这些功能。
章节
- 0:00 - Introduction
- 1:10 - Richer forecast details
- 10:03 - Highlight weather changes
- 14:10 - Faster data transfer
资源
- Forum: Maps & Location
- Request authentication for WeatherKit REST API
- WeatherKit
- WeatherKit REST API
相关视频
WWDC22
-
下载Array
-
-
2:40 - Fetch Precipitation Amount
import CoreLocation import Foundation import WeatherKit extension CLLocation { static var newYork: CLLocation { CLLocation(latitude: 50.710, longitude: -74.006) } } let hourlyPrecipitation = try await WeatherService() .weather(for: .newYork, including: .hourly) .map(\.precipitationAmount)
-
3:25 - Fetch Precipitation Amount (REST)
https://weatherkit.apple.com/api/v2/weather/en-US/40.710/-74.006?dataSets=forecastHourly&relativeHourlyStart=0&relativeHourlyEnd=1&hourlyRelativeTo=now&timezone=America/New_York
-
6:05 - Weather Changes
import CoreLocation import Foundation import WeatherKit extension Date { var isTomorrow: Bool { return Calendar.current.isDateInTomorrow(self) } } let changes = try await WeatherService() .weather(for: .newYork, including: .changes) let lowTemperatureChanges = changes? .filter(\.date.isTomorrow) .map(\.lowTemperature) if let lowTemperatureChanges, lowTemperatureChanges.contains(.decrease) { // Lower temperatures expected tomorrow }
-
6:43 - Weather Changes (REST)
https://weatherkit.apple.com/api/v2/weather/en-US/40.710/-74.006?dataSets=weatherChanges
-
8:17 - Historical Comparisons
import CoreLocation import Foundation import WeatherKit let mostSignificant = try await WeatherService() .weather(for: .newYork, including: .historicalComparisons)? .first switch mostSignificant { case .highTemperature(let trend), .lowTemperature(let trend): // Display temperature trend break case .some, .none: break }
-
8:36 - Historical Comparisons (REST)
https://weatherkit.apple.com/api/v2/weather/en-US/40.710/-74.006?dataSets=historicalComparisons
-
11:11 - Monthly Statistics
import CoreLocation import Foundation import WeatherKit let averagePrecipitation = try await WeatherService() .monthlyStatistics( for: .newYork, startMonth: 1, endMonth: 12, including: .precipitation ) let averagePrecipitationAmountsPerMonth = Dictionary( grouping: averagePrecipitation, by: \.month )
-
11:41 - Monthly Statistics (REST)
https://weatherkit.apple.com/api/v2/statistics/monthly/40.710/-74.006?dataSets=precipitation&start=1&end=12
-
12:52 - Daily Summary
import CoreLocation import Foundation import WeatherKit extension Date { static var thirtyDaysAgo: Date { return Calendar.current.date(byAdding: .day, value: -30, to: .now)! } } let pastThirtyDaysSummary = try await WeatherService() .dailySummary( for: .newYork, forDaysIn: DateInterval(start: .thirtyDaysAgo, end: .now), including: .precipitation ) .first if let pastThirtyDaysSummary { // We have a daily weather summary for each day in the past 30 days }
-
13:22 - Daily Summary (REST)
https://weatherkit.apple.com/api/v2/summary/daily/40.710/-74.006?dataSets=precipitation&start=2024-05-12&end=2024-06-10
-
-
正在查找特定内容?在上方输入一个主题,就能直接跳转到相应的精彩内容。
提交你查询的内容时出现错误。请检查互联网连接,然后再试一次。