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
 

Videos

Abrir menú Cerrar menú
  • Colecciones
  • Todos los videos
  • Información

Más videos

  • Información
  • Código
  • Moderniza tu app de AppKit

    Actualiza tu app de AppKit para que se ajuste a las convenciones modernas de macOS. Explora el manejo de entradas mediante eventos de control y reconocedores de gestos, y trasciende los bucles de seguimiento tradicionales. Mejora la navegación por teclado en tu app, implementa una restauración fluida del estado tras los reinicios y aprovecha las nuevas API de concentricidad de esquinas, que permiten que tu interfaz se integre a la perfección con la estética de macOS.

    Capítulos

    • 0:00 - Introducción
    • 1:06 - Métodos de entrada modernos
    • 1:27 - Procesamiento moderno de eventos mediante reconocedores de gestos
    • 2:25 - Selección, menús contextuales y arrastrar y soltar
    • 3:52 - Selección de texto en vistas personalizadas
    • 4:26 - Eventos de control y reconocedores de gestos
    • 5:51 - Navegación con teclado y elementos de estado
    • 8:57 - Continuidad entre lanzamientos
    • 9:08 - Cierre controlado de la app
    • 9:55 - Restauración del estado
    • 14:09 - Actualizaciones de diseño
    • 14:24 - Actualizaciones de Liquid Glass en macOS 27
    • 15:41 - Concentricidad
    • 16:59 - Próximos pasos

    Recursos

    • Use SwiftUI with AppKit
    • Restoring your app’s state with AppKit
    • Gestures
    • TN3212: Adopting gesture recognizers for Sidecar touch support
    • NSControl.Events
      • Video HD
      • Video SD

    Videos relacionados

    WWDC26

    • Usa SwiftUI con AppKit y UIKit
  • Buscar este video…
    • 3:35 - Modern dragging delegate

      // Modern dragging delegate methods
      func tableView(_ tableView: NSTableView,
              pasteboardWriterForRow row: Int) -> (any NSPasteboardWriting)? {
          let pasteboardItem = NSPasteboardItem()
          pasteboardItem.setString(..., forType: .string)
          return pasteboardItem
      }
    • 4:55 - Control events

      // Use control events
      let button = NSButton()
      button.addTarget(
          self,
          action: #selector(trackingEndedOutsideHandler),
          for: .trackingEndedOutside
      )
    • 5:44 - hitTest override

      override func hitTest(_ point: NSPoint) -> NSView? {
          return nil
      }
    • 6:24 - autorecalculatesKeyViewLoop

      window.autorecalculatesKeyViewLoop = true
    • 7:37 - Expanded interface delegate — setup

      // Set the expanded interface delegate
      @main class LightAppDelegate: NSObject, NSApplicationDelegate {
          lazy var lightStatusItem: NSStatusItem = { ... }()
      
          func applicationDidFinishLaunching(_ notification: Notification) {
              // ...
              lightStatusItem.expandedInterfaceDelegate = self
          }
      }
    • 7:52 - Expanded interface delegate — methods

      // Implement the delegate methods
      extension LightAppDelegate: NSStatusItemExpandedInterfaceDelegate {
          // ...
          func statusItem(_ statusItem: NSStatusItem, didBegin session:
                          NSStatusItemExpandedInterfaceSession) {
              // Show window
          }
          func statusItemDidEndExpandedInterfaceSession(
              _ statusItem: NSStatusItem, animated: Bool) {
              // Hide window
          }
          func selectedAction() {
              // Take the action
              // Cancel session to request window dismissal
              lightStatusItem.expandedInterfaceSession?.cancel()
          }
      }
    • 8:16 - Expanded interface delegate — cancel

      // Cancel the session when dismissing
      extension LightAppDelegate: NSStatusItemExpandedInterfaceDelegate {
          // ...
          func statusItem(_ statusItem: NSStatusItem, didBegin session:
                          NSStatusItemExpandedInterfaceSession) {
              // Show window
          }
          func statusItemDidEndExpandedInterfaceSession(
              _ statusItem: NSStatusItem, animated: Bool) {
              // Hide window
          }
          func selectedAction() {
              // Take the action
              // Cancel session to request window dismissal
              lightStatusItem.expandedInterfaceSession?.cancel()
          }
      }
    • 9:45 - preventsApplicationTerminationWhenModal

      window.preventsApplicationTerminationWhenModal = false
    • 10:18 - Set window identifiers for state restoration

      // Set window identifiers for state restoration
      @MainActor class MainWindowController: NSWindowController, NSWindowDelegate {
          // ...
          convenience init() {
              let window = NSWindow( ... )
              // ...
              window.identifier = NSUserInterfaceItemIdentifier(WindowIdentifiers.mainWindow)
              window.setFrameAutosaveName(WindowIdentifiers.mainWindow)
              window.isRestorable = true
              window.restorationClass = WindowRestorationHandler.self
              // ...
          }
      }
    • 11:04 - encodeRestorableState

      // Preserve state to recreate the UI
      @MainActor class MainWindowController: NSWindowController, NSWindowDelegate {
          // ...
          override func encodeRestorableState(with coder: NSCoder) {
              super.encodeRestorableState(with: coder)
              // ...
              coder.encode(selectedProduct?.identifier.uuid,
                          forKey: RestorationKeys.productIdentifier)
              // ...
          }
          // ...
      }
    • 11:50 - invalidateRestorableState

      // Invalidate restorable state when the view hierarchy changes
      @MainActor class MainWindowController: NSWindowController, NSWindowDelegate {
          // ...
          convenience init() {
              // ...
              splitViewController.onProductSelected = { [weak self] product in
                  self?.invalidateRestorableState()
              }
          }
      }
    • 12:26 - restoreWindow(withIdentifier:)

      // Restore windows
      class WindowRestorationHandler: NSObject, NSWindowRestoration {
          static func restoreWindow(
              withIdentifier identifier: NSUserInterfaceItemIdentifier,
              state: NSCoder,
              completionHandler: @escaping (NSWindow?, Error?) -> Void
          ) {
              //...
              if identifier == .mainWindow, let window = appDelegate.mainWindowController?.window {
                  completionHandler(window, nil)
              } else if identifier == .imageWindow {
                  let controller = ImageWindowController()
                  appDelegate.imageWindowControllers.append(controller)
                  completionHandler(controller.window, nil)
              } else {
                  completionHandler(nil, error)
              }
          }
      }
    • 13:29 - restoreState

      // Restore window UI
      @MainActor class MainWindowController: NSWindowController, NSWindowDelegate {
          //...
          override func restoreState(with coder: NSCoder) {
              super.restoreState(with: coder)
              if let productId = coder.decodeObject(
                  of: [NSString.self],
                  forKey: RestorationKeys.productIdentifier) as? String {
                  splitViewController?.selectedProductId = productId
              }
              //...
          }
      }
    • 16:11 - cornerConfiguration

      // Subclass NSView to override cornerConfiguration
      class LocalWeatherView: NSView {
          // ...
          override var cornerConfiguration: NSViewCornerConfiguration? {
              let radius: NSViewCornerRadius = .containerConcentric(minimumCornerRadius)
              return .uniformCorners(radius: radius)
          }
          // ...
      }

Developer Footer

  • Videos
  • WWDC26
  • Moderniza tu app de AppKit
  • 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