2016-09-17 2 views
1

Xcode 8 및 Swift 3.0으로 마이그레이션 한 후 Xcode 7.3 및 Swift 2 *에서 다음 기능이 작동했습니다. 컴파일 할 때 다음 오류가 발생했습니다.Xcode 8 및 Swift 3.0으로 마이그레이션 할 때 Xcode Healthkit 인증 기능 오류가 발생했습니다.

cannot call value of non-function type ((Bool, _ error:NSError?) -> Void)!

 func authorizeHealthKit(_ completion: ((_ success:Bool, _ error:NSError?) -> Void)!) { 
      healthKitStore = HKHealthStore() 
      let typesSet:Set<HKSampleType> = [ 
        HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bodyTemperature)!, 
        HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.respiratoryRate)!, 
        HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bloodPressureSystolic)!, 
        HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bloodPressureDiastolic)!, 
        HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bodyMass)!, 
        HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.heartRate)!, 
        HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.oxygenSaturation)!] 


       healthKitStore?.requestAuthorization(toShare: typesSet, read: typesSet, completion: { (boolVal, error) in 
        completion(success: boolVal, error: error) //<-- compile error here 
      }) 
    } 
+0

[Markdown 또는 HTML을 사용하여 게시물의 서식을 지정하는 방법은 무엇입니까?] (http://stackoverflow.com/help/formatting) – buhtz

답변

0

는 다음과 같이 선택하여 완료 핸들러를 만들어보십시오 :

완료 (성공 : boolVal, 오류 : 오류) 또한

을 애플 API의 documentatio에서 주목 n :

중요 iOS 10.0 이상으로 링크 된 iOS 앱은 Info.plist 파일에 액세스해야하는 데이터 유형에 대한 사용법 설명 키를 포함해야합니다. 그렇지 않으면 충돌합니다. HealthKit 데이터를 구체적으로 액세스하고 업데이트하려면 NSHealthShareUsageDescription 및 NSHealthUpdateUsageDescription 키가 각각 포함되어야합니다.

희망이 도움이됩니다.

관련 문제