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
  • What's new in CareKit

    Build feature-rich research and care apps with CareKit: Learn about the latest advancements to our health framework, including new views for its modular architecture, improvements to the data store, and tighter integration with other frameworks on iOS. And discover how the open-source community continues to leverage CareKit to allow developers to push the boundaries of digital health — all while preserving privacy.

    Recursos

    • Research and Care Website
    • CareKit Repository
      • Video HD
      • Video SD

    Videos relacionados

    WWDC20

    • Beyond counting steps
    • Getting started with HealthKit
    • Handling FHIR without getting burned
    • What's new in ResearchKit
  • Buscar este video…
    • 2:23 - Simple Task View

      import CareKitUI
      import SwiftUI
      
      struct MySimpleTaskView: View {
      
          var body: some View {
              SimpleTaskView(
                  title: Text("Stretches"),
                  detail: Text("15 minutes"),
                  isComplete: false)
          }
      }
    • 2:52 - Simple Task View - View Modifiers

      import CareKitUI
      import SwiftUI
      
      struct MySimpleTaskView: View {
      
          var body: some View {
              SimpleTaskView(
                  title: Text("Stretches").fontWeight(.thin),
                  detail: Text("15 minutes"),
                  isComplete: false)
          }
      }
    • 3:42 - Simple Task View - Custom Header

      struct MySimpleTaskView: View {
      
          var body: some View {
              SimpleTaskView(isComplete: false) {                
                  HStack {
                      RoundedRectangle(cornerRadius: 5)
                          .fill(Color.accentColor)
                          .frame(width: 5)         
                      HeaderView(
                          title: Text("Stretches"),
                          detail: Text("15 minutes"))
                  }
                  .padding()
              }
          }
      }
    • 4:29 - Simple Task View - Appending Views

      import CareKitUI
      import SwiftUI
      
      struct MyComposedSimpleTaskView: View {
      
          var body: some View {
              CardView {
                  VStack(alignment: .leading) {
      								MySimpleTaskView()
                      Divider()
                      Text("...")
                          .font(.caption)
                          .foregroundColor(.secondary)    
                  }.padding()
              }        
          }
      }
    • 5:24 - Labeled Value Task View

      import CareKitUI
      import SwiftUI
      
      struct MyLabeledValueTaskView: View {
      
          var body: some View {
              LabeledValueTaskView(
                  title: Text("Heart Rate"),
                  detail: Text("Most recent measurement")
                  state: .complete(
                      Text("62"),
                      Text("BPM")
                  ))
          }
      }
    • 5:57 - Numeric Progress Task View

      import CareKitUI
      import SwiftUI
      
      struct MyNumericProgressView: View {
      
          var body: some View {
              NumericProgressTaskView(
                  title: Text("Exercise Minutes"),
                  detail: Text("Anytime"),
                  instructions: Text("..."),
                  progress: Text("22"),
                  goal: Text("30"),
                  isComplete: false)
          }
      }
    • 6:28 - Featured Content View

      import CareKitUI
      import UIKit
      
      let featureView = OCKFeaturedContentView()
      
      featureView.imageView.image = UIImage(named: "groceries")
      featureView.label.text = "Easy & Healthy Recipes"
    • 6:58 - Detail View

      import CareKitUI
      import UIKit
      
      let styledHTML = OCKDetailView.StyledHTML(
        html: html, 
        css: css)
      
      let detailView = OCKDetailView(
        html: styledHTML, 
        showsCloseButton: true)
      
      detailView.imageView.image = UIImage(named: "groceries")
    • 7:41 - Link View

      import CareKitUI
      import SwiftUI
      
      struct MyLinkView: View {
      
          var body: some View {
              LinkView(
                  title: Text("Physical Therapist Appointment"),
                  instructions: Text("..."),
                  links: [
                      // ...
                      .website(
                          "https://www.apple.com", 
                          title: "Website")
                      // ...
              ])
          }       
      }
    • 8:56 - Synchronized Task View 1

      // Synchronized Task View
      
      import CareKit
      import CareKitUI
      import SwiftUI
      
      struct MySynchronizedTaskView: View {
      
          let storeManager: OCKSynchronizedStoreManager
      
          var body: some View {
              CareKit.SimpleTaskView(
                  taskID: "stretch",
                  eventQuery: OCKEventQuery(for: Date()),
                  storeManager: storeManager)
      
          }
      }
    • 9:26 - Synchronized Task View 2

      @State private var isShowingSurvey = false
      
      var body: some View {
          CareKit.SimpleTaskView(
              taskID: "researchKitSurveyTask",
              eventQuery: OCKEventQuery(for: Date()),
              storeManager: storeManager) { controller in
      
                  CareKitUI.SimpleTaskView(
                      title: Text(controller.viewModel?.title ?? ""),
                      detail: controller.viewModel?.detail.map(Text.init),
                      isComplete: controller.viewModel?.isComplete ?? false) {
                          isShowingSurvey = true
                      }
              }  
              .popover(isPresented: $isShowingSurvey) {
                  ResearchKitSurvey()
              }
      }
    • 13:43 - Setting up the store

      // Setting up the Store
      
      import CareKit
      import CareKitStore
      
      let coreDataStore = OCKStore(name: "core-data-store")
      let healthKitPassthroughStore = OCKHealthKitPassthroughStore(name: "hk-passthrough—store")
      
      let coordinator = OCKStoreCoordinator()
      coordinator.attach(store: coreDataStore)
      coordinator.attach(eventStore: healthKitPassthroughStore)
      
      let storeManager = OCKSynchronizedStoreManager(wrapping: coordinator)
    • 14:15 - Adding HealthKit linked tasks to the store

      // Adding HealthKit Linked Tasks to the Store
      
      let schedule = OCKSchedule.dailyAtTime(
          hour: 8,
          minutes: 0, 
          start: Date(),
          end: nil,
          text: nil, 
          duration: .allDay, 
          targetValues: [OCKOutcomeValue(30.0, units: "Minutes")])
      
      let link = OCKHealthKitLinkage(
          quantityIdentifier: .appleExerciseTime, 
          quantityType: .cumulative,
          unit: .minute())
      
      let steps = OCKHealthKitTask(
          id: "exerciseMinutes",
          title: "Exercise Minutes",
          carePlanUUID: nil,
          schedule: schedule,
          healthKitLinkage: link)
      
      storeManager.store.addAnyTask(steps)
    • 16:57 - Encoding and decoding FHIR data

      // Encoding and Decoding FHIR Data
      
      import CareKitStore
      import CareKitFHIR
      
      let coder = OCKR4PatientCoder()
      
      // CareKit entity to FHIR data
      let patient = OCKPatient(...)
      let json = try! coder.encode(patient)
      
      // FHIR data to CareKit entity
      let data: Data = //... 
      let resourceData = OCKFHIRResourceData<R4, JSON>(data: data)
      let patient: OCKPatient = try! coder.decode(resourceData)
    • 17:49 - Customizing the data mapping 1

      // Customizing the Data Mapping
      
      // Encoding process
      coder.setFHIRName = { name, fhirPatient in // ModelsR4.Patient
      
          let humanName = HumanName()
          humanName.family = name.familyName.map { FHIRPrimitive(FHIRString($0)) }
          humanName.given = name.givenName.map { [FHIRPrimitive(FHIRString($0))] }
          
          fhirPatient.name = [humanName]
      }
    • 18:10 - Customizing the data mapping 2

      // Customizing the Data Mapping
      
      // Encoding process
      coder.setFHIRName = { name, fhirPatient in // ModelsR4.Patient
      
          let humanName = HumanName()
          humanName.family = name.familyName.map { FHIRPrimitive(FHIRString($0)) }
          humanName.given = name.givenName.map { [FHIRPrimitive(FHIRString($0))] }
          
          fhirPatient.name = [humanName]
      }
    • 25:56 - Creating the remote

      private lazy var remote = OCKWatchConnectivityPeer()
    • 26:09 - Setting up the remote store

      private lazy var store = OCKStore(name: "sample-store", remote: remote)
    • 26:18 - import WatchConnectivity

      import WatchConnectivity
    • 26:33 - Setting up the Watch Connectivity Session

      WCSession.default.delegate = sessionDelegate
      WCSession.default.activate()
    • 26:53 - Stub out session delegate class

      class SessionDelegate: NSObject, WCSessionDelegate {
      
          let remote: OCKWatchConnectivityPeer
          let store: OCKStore
      
          init(remote: OCKWatchConnectivityPeer, store: OCKStore) {
              self.remote = remote
              self.store = store
          }
      
          func session(
              _ session: WCSession,
              activationDidCompleteWith activationState: WCSessionActivationState,
              error: Error?) {
      
              print("New session state: \(activationState)")
          }
      
          func session(
              _ session: WCSession,
              didReceiveMessage message: [String: Any],
              replyHandler: @escaping ([String: Any]) -> Void) {
      
              print("Received message from peer!")
          }
      }
    • 27:02 - Kick off first synchronization

      if activationState == .activated {
          store.synchronize { error in
              print(error?.localizedDescription ?? "Successful sync!")
          }
      }
    • 27:11 - Forwarding replies on CareKit's behalf

      remote.reply(to: message, store: store) { reply in
      
          print("Sending reply to peer!")
      
          replyHandler(reply)
      }
    • 27:39 - Creating the delegate

      private lazy var sessionDelegate = SessionDelegate(remote: remote, store: store)
    • 28:10 - Setting up the synchronized store manager

      private(set) lazy var storeManager = OCKSynchronizedStoreManager(wrapping: store)
    • 28:27 - Defining a new environment key

      private struct StoreManagerKey: EnvironmentKey {
      
          static var defaultValue: OCKSynchronizedStoreManager {
      
              let extensionDelegate = WKExtension.shared().delegate as! ExtensionDelegate
      
              return extensionDelegate.storeManager
          }
      }
    • 28:51 - Defining a store manager environment value

      extension EnvironmentValues {
          
          var storeManager: OCKSynchronizedStoreManager {
              get {
                  self[StoreManagerKey.self]
              }
      
              set {
                  self[StoreManagerKey.self] = newValue
              }
          }
      }
    • 28:57 - Adding an environment variable to the view

      @Environment(\.storeManager) private var storeManager
    • 29:04 - Setting up the scroll view

      ScrollView {
      
      }.accentColor(Color(#colorLiteral(red: 0.9960784314, green: 0.3725490196, blue: 0.368627451, alpha: 1)))
    • 29:22 - Displaying the stretch task card

      InstructionsTaskView(
          taskID: "stretch",
          eventQuery: OCKEventQuery(for: Date()),
          storeManager: storeManager)
    • 29:33 - Displaying the muscle cramps task card

      SimpleTaskView(
          taskID: "cramps",
          eventQuery: OCKEventQuery(for: Date()),
          storeManager: storeManager) { controller in
          
          .init(title: Text(controller.viewModel?.title ?? ""),
                detail: nil,
                isComplete: controller.viewModel?.isComplete ?? false,
                action: controller.viewModel?.action ?? {})
      }

Developer Footer

  • Videos
  • WWDC20
  • What's new in CareKit
  • 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