View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Bring context to today’s weather

    Harness the power of WeatherKit to get detailed weather forecast data such as precipitation amounts by type, cloud cover by altitude, or maximum wind speed. Find out how you can summarize weather by different parts of the day and highlight significant upcoming changes to temperature or precipitation. Understand how you can compare current weather to the past through our Historical Comparisons dataset and dive into historical weather statistics for any location in the world. We'll also explore how you can do all of this faster with our Swift and REST APIs.

    Chapitres

    • 0:00 - Introduction
    • 1:10 - Richer forecast details
    • 10:03 - Highlight weather changes
    • 14:10 - Faster data transfer

    Ressources

    • WeatherKit REST API
    • Request authentication for WeatherKit REST API
    • Forum: Maps & Location
    • WeatherKit
      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC22

    • Meet WeatherKit
  • Rechercher dans cette vidéo…
    • 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

Developer Footer

  • Vidéos
  • WWDC24
  • Bring context to today’s weather
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines