2016-03-31 3 views
0

healthKitフレームワークを使用して、健康アプリで自分のiPhoneとApple watchの歩数を読み込もうとしました。しかし、私がHKQuantitySampleHKDeviceオブジェクトを照会すると、localIdentifierUDIDeviceIdentifierは表示されませんでした。 なぜ彼らは空だったのか? 情報を記録していないソースが原因でしたか?空のlocalIdentifierとUDIDeviceIdentifierを持つHKDevice

要求

func getFitness() { 
    let stepsCount = HKQuantityType.quantityTypeForIdentifier(
     HKQuantityTypeIdentifierStepCount) 

    let stepsSampleQuery = HKSampleQuery(sampleType: stepsCount!, 
     predicate: nil, 
     limit: 10000, 
     sortDescriptors: nil) { 
      (query, results, error) in 
      if let results = results as? [HKQuantitySample] { 
       for result in results { 
        print("device: \(result.device) steps:\(result)") 
       } 
      } 
    } 

    self.healthStore?.executeQuery(stepsSampleQuery) 
} 

応答

device: <<HKDevice: 0x14e238380>, name:iPhone, manufacturer:Apple, model:iPhone, hardware:iPhone7,1, software:9.2.1> steps:63 count "iPhone6plus" (9.2.1) "iPhone" 2016-03-31 09:11:13 +0800 2016-03-31 09:11:58 +0800 

device: <<HKDevice: 0x14e2385a0>, name:Apple Watch, manufacturer:Apple, model:Watch, hardware:Watch1,1, software:2.1> steps:15 count "Apple Watch" (2.1) "Apple Watch" 2016-03-31 11:15:23 +0800 2016-03-31 11:15:31 +0800 
+0

http://stackoverflow.com/help/how-to-ask – StefanS

答えて

0

localIdentifierUDIDeviceIdentifierは、iPhoneとAppleウォッチソースのHealthKitによって記録されていません。

関連する問題