Documentation Archive Developer
Search

HealthKit Changes for Swift

HealthKit

Modified HKObjectType
Declaration
From
class HKObjectType : NSObject, NSSecureCoding, NSCopying {
    var identifier: String { get }
    init()
    class func quantityTypeForIdentifier(_ identifier: String) -> HKQuantityType?
    class func categoryTypeForIdentifier(_ identifier: String) -> HKCategoryType?
    class func characteristicTypeForIdentifier(_ identifier: String) -> HKCharacteristicType?
    class func correlationTypeForIdentifier(_ identifier: String) -> HKCorrelationType?
    class func workoutType() -> HKWorkoutType
}
To
class HKObjectType : NSObject, NSSecureCoding, NSCopying {
    var identifier: String { get }
    init()
    class func quantityTypeForIdentifier(_ identifier: String) -> HKQuantityType?
    class func categoryTypeForIdentifier(_ identifier: String) -> HKCategoryType?
    class func characteristicTypeForIdentifier(_ identifier: String) -> HKCharacteristicType?
    class func correlationTypeForIdentifier(_ identifier: String) -> HKCorrelationType?
    class func workoutType() -> HKWorkoutType
    class func activitySummaryType() -> HKActivitySummaryType
}

Modified HKQuery
Declaration
From
class HKQuery : NSObject {
    var sampleType: HKSampleType { get }
    var predicate: NSPredicate? { get }
    init()
}
extension HKQuery {
    class func predicateForObjectsWithMetadataKey(_ key: String) -> NSPredicate
    class func predicateForObjectsWithMetadataKey(_ key: String, allowedValues allowedValues: [AnyObject]) -> NSPredicate
    class func predicateForObjectsWithMetadataKey(_ key: String, operatorType operatorType: NSPredicateOperatorType, value value: AnyObject) -> NSPredicate
    class func predicateForObjectsFromSource(_ source: HKSource) -> NSPredicate
    class func predicateForObjectsFromSources(_ sources: Set<HKSource>) -> NSPredicate
    class func predicateForObjectsFromSourceRevisions(_ sourceRevisions: Set<HKSourceRevision>) -> NSPredicate
    class func predicateForObjectsFromDevices(_ devices: Set<HKDevice>) -> NSPredicate
    class func predicateForObjectsWithDeviceProperty(_ key: String, allowedValues allowedValues: Set<String>) -> NSPredicate
    class func predicateForObjectWithUUID(_ UUID: NSUUID) -> NSPredicate
    class func predicateForObjectsWithUUIDs(_ UUIDs: Set<NSUUID>) -> NSPredicate
    class func predicateForObjectsWithNoCorrelation() -> NSPredicate
    class func predicateForObjectsFromWorkout(_ workout: HKWorkout) -> NSPredicate
}
extension HKQuery {
    class func predicateForSamplesWithStartDate(_ startDate: NSDate?, endDate endDate: NSDate?, options options: HKQueryOptions) -> NSPredicate
}
extension HKQuery {
    class func predicateForQuantitySamplesWithOperatorType(_ operatorType: NSPredicateOperatorType, quantity quantity: HKQuantity) -> NSPredicate
}
extension HKQuery {
    class func predicateForCategorySamplesWithOperatorType(_ operatorType: NSPredicateOperatorType, value value: Int) -> NSPredicate
}
extension HKQuery {
    class func predicateForWorkoutsWithWorkoutActivityType(_ workoutActivityType: HKWorkoutActivityType) -> NSPredicate
    class func predicateForWorkoutsWithOperatorType(_ operatorType: NSPredicateOperatorType, duration duration: NSTimeInterval) -> NSPredicate
    class func predicateForWorkoutsWithOperatorType(_ operatorType: NSPredicateOperatorType, totalEnergyBurned totalEnergyBurned: HKQuantity) -> NSPredicate
    class func predicateForWorkoutsWithOperatorType(_ operatorType: NSPredicateOperatorType, totalDistance totalDistance: HKQuantity) -> NSPredicate
}
To
class HKQuery : NSObject {
    var objectType: HKObjectType? { get }
    var sampleType: HKSampleType? { get }
    var predicate: NSPredicate? { get }
    init()
}
extension HKQuery {
    class func predicateForObjectsWithMetadataKey(_ key: String) -> NSPredicate
    class func predicateForObjectsWithMetadataKey(_ key: String, allowedValues allowedValues: [AnyObject]) -> NSPredicate
    class func predicateForObjectsWithMetadataKey(_ key: String, operatorType operatorType: NSPredicateOperatorType, value value: AnyObject) -> NSPredicate
    class func predicateForObjectsFromSource(_ source: HKSource) -> NSPredicate
    class func predicateForObjectsFromSources(_ sources: Set<HKSource>) -> NSPredicate
    class func predicateForObjectsFromSourceRevisions(_ sourceRevisions: Set<HKSourceRevision>) -> NSPredicate
    class func predicateForObjectsFromDevices(_ devices: Set<HKDevice>) -> NSPredicate
    class func predicateForObjectsWithDeviceProperty(_ key: String, allowedValues allowedValues: Set<String>) -> NSPredicate
    class func predicateForObjectWithUUID(_ UUID: NSUUID) -> NSPredicate
    class func predicateForObjectsWithUUIDs(_ UUIDs: Set<NSUUID>) -> NSPredicate
    class func predicateForObjectsWithNoCorrelation() -> NSPredicate
    class func predicateForObjectsFromWorkout(_ workout: HKWorkout) -> NSPredicate
}
extension HKQuery {
    class func predicateForSamplesWithStartDate(_ startDate: NSDate?, endDate endDate: NSDate?, options options: HKQueryOptions) -> NSPredicate
}
extension HKQuery {
    class func predicateForQuantitySamplesWithOperatorType(_ operatorType: NSPredicateOperatorType, quantity quantity: HKQuantity) -> NSPredicate
}
extension HKQuery {
    class func predicateForCategorySamplesWithOperatorType(_ operatorType: NSPredicateOperatorType, value value: Int) -> NSPredicate
}
extension HKQuery {
    class func predicateForWorkoutsWithWorkoutActivityType(_ workoutActivityType: HKWorkoutActivityType) -> NSPredicate
    class func predicateForWorkoutsWithOperatorType(_ operatorType: NSPredicateOperatorType, duration duration: NSTimeInterval) -> NSPredicate
    class func predicateForWorkoutsWithOperatorType(_ operatorType: NSPredicateOperatorType, totalEnergyBurned totalEnergyBurned: HKQuantity) -> NSPredicate
    class func predicateForWorkoutsWithOperatorType(_ operatorType: NSPredicateOperatorType, totalDistance totalDistance: HKQuantity) -> NSPredicate
}
extension HKQuery {
    class func predicateForActivitySummaryWithDateComponents(_ dateComponents: NSDateComponents) -> NSPredicate
    class func predicateForActivitySummariesBetweenStartDateComponents(_ startDateComponents: NSDateComponents, endDateComponents endDateComponents: NSDateComponents) -> NSPredicate
}

Declaration
From
var sampleType: HKSampleType { get }
To
var sampleType: HKSampleType? { get }

Declaration
From
var HKObjectQueryNoLimit: Int32 { get }
To
let HKObjectQueryNoLimit: Int