Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当授权HealthKitStore时,iOS8应用程序在Xcode6.3上崩溃_Ios_Healthkit_Hkhealthstore - Fatal编程技术网

当授权HealthKitStore时,iOS8应用程序在Xcode6.3上崩溃

当授权HealthKitStore时,iOS8应用程序在Xcode6.3上崩溃,ios,healthkit,hkhealthstore,Ios,Healthkit,Hkhealthstore,我已经在我的应用程序中集成了HealthKit。但是,当我授权HealthKitStore时,它不允许我授权。 以下是我用来授权HealthKitStore的代码: var healthStore: HKHealthStore = HKHealthStore() let dataTypesToWrite = [ HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass), HKObjectTy

我已经在我的应用程序中集成了
HealthKit
。但是,当我授权
HealthKitStore
时,它不允许我授权。 以下是我用来授权HealthKitStore的代码:

 var healthStore: HKHealthStore = HKHealthStore()

 let dataTypesToWrite = [
  HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass),
  HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeight),
  HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMassIndex)
]

let dataTypesToRead = [
  HKObjectType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierDateOfBirth),
  HKObjectType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierBiologicalSex),
  HKObjectType.characteristicTypeForIdentifier(HKQuantityTypeIdentifierStepCount)
]

healthStore.requestAuthorizationToShareTypes(Set<NSObject>(arrayLiteral: dataTypesToWrite),
  readTypes: Set<NSObject>(arrayLiteral: dataTypesToRead), completion: {
    (success, error) in
    if success {
      println("User completed authorisation request.")
    } else {
      println("The user cancelled the authorisation request. \(error)")
    }
})

该异常表示您正在将包含
HKObjectTypes
数组的集合传递给
HealthKit
。它应该是一组
HKObjectTypes

2015-05-11 12:40:59.682 HKTutorial[1036:362577] -[Swift._SwiftDeferredNSArray _allowAuthorizationForSharingWithEntitlements:]: unrecognized selector sent to instance 0x170237d80
2015-05-11 12:40:59.683 HKTutorial[1036:362577] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swift._SwiftDeferredNSArray _allowAuthorizationForSharingWithEntitlements:]: unrecognized selector sent to instance 0x170237d80'
*** First throw call stack:
(0x18532c2d8 0x196b500e4 0x1853333a4 0x185330154 0x185232ccc 0x186444cc8 0x186444afc 0x1864151f4 0x186414e38 0x186414d4c 0x10003c858 0x10003d35c 0x10003d4a4 0x189e95474 0x189f4f790 0x189df0240 0x189d606ec 0x1852e42a4 0x1852e1230 0x1852e1610 0x18520d2d4 0x18ea236fc 0x189dd2fac 0x100022198 0x1971cea08)
libc++abi.dylib: terminating with uncaught exception of type NSException