17.10 · Contacts, EventKit, HealthKit units and sensor availability
These frameworks guard personal data, but a lot of their model can be exercised and understood without any permission.
Mental model. Know the value types (contacts, recurrence rules, quantities) and the availability checks; authorization is a separate gate.
People and calendars
Contacts and EventKit models.
- What can you do with the Contacts framework without permission, and how do formatters and vCards behave?
CNMutableContact and the value types around it (CNLabeledValue, CNPhoneNumber, CNMutablePostalAddress) are plain objects: you can build, format and serialise… - How is an EventKit event modelled: recurrence rules, alarms, calendars, and why does saving fail?
An EKEvent is created from an EKEventStore and is not yet in any calendar: in the run calendar and eventIdentifier are nil, and save fails with EKErrorDomain…
Body and sensors
HealthKit quantities and Core Motion availability.
- How do HealthKit units and aggregation styles work, and why does converting mg/dL to mmol/L crash?
An HKQuantity pairs a value with an HKUnit, and conversion is only legal between compatible units: pounds convert to kilograms (150 lb is 68.04 kg), but mg/dL… - How do you detect which sensors and health data exist at runtime, and what does the simulator report?
Every sensor API has a class or instance availability check: CMMotionManager.isAccelerometerAvailable, isGyroAvailable, isDeviceMotionAvailable…
More in System frameworks
- 17.1 · UserNotifications, APNs and how a push actually gets delivered
- 17.2 · Core Location and MapKit
- 17.3 · Contacts, Calendar, Photos, HealthKit and Core Motion
- 17.4 · CloudKit, StoreKit 2 and PassKit
- 17.5 · AuthenticationServices and passkeys, Spotlight, Handoff and user activities
- 17.6 · Live Activities, WeatherKit, App Clips and CarPlay
- 17.7 · A checklist for learning any Apple framework
- 17.8 · APNs tokens, payload budgets and notification triggers
- 17.9 · Cleaning location fixes, choosing geofences, and map geometry
- 17.11 · Records, system fields and CKError handling
- 17.12 · Passkey assertions, Apple ID tokens and Live Activity payloads