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.

  1. What can you do with the Contacts framework without permission, and how do formatters and vCards behave? 17.10.1 · L3
    CNMutableContact and the value types around it (CNLabeledValue, CNPhoneNumber, CNMutablePostalAddress) are plain objects: you can build, format and serialise…
  2. How is an EventKit event modelled: recurrence rules, alarms, calendars, and why does saving fail? 17.10.2 · L3
    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.

  1. How do HealthKit units and aggregation styles work, and why does converting mg/dL to mmol/L crash? 17.10.3 · L5
    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…
  2. How do you detect which sensors and health data exist at runtime, and what does the simulator report? 17.10.4 · L3
    Every sensor API has a class or instance availability check: CMMotionManager.isAccelerometerAvailable, isGyroAvailable, isDeviceMotionAvailable…

More in System frameworks