我收到一個錯誤「表達式類型HKAnchoredObjectQuery'是不明確的,沒有更多的內容」在healthkit代碼行「let heartRateQuery = HKAnchoredObjectQuery(type:數據類型,謂詞:nil,錨點:錨點,限制:Int(HKObjectQueryNoLimit)){(query,sampleObjects,deletedObjects,newAnchor,error) - >swift error'表達式類型'HKAnchoredObjectQuery'是不明確的沒有更多的上下文
該代碼是從一個示例項目複製粘貼的,在這一行上運行沒有錯誤,進入我的項目,現在它帶來了這個錯誤。我是一個初學者,會欣賞你的提示。
代碼:
func createHeartRateStreamingQuery(workoutStartDate: NSDate) -> HKQuery? {
// adding predicate will not work
//let predicate = HKQuery.predicateForSamplesWithStartDate(workoutStartDate, endDate: nil, options: HKQueryOptions.None)
guard let quantityType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeartRate) else { return nil }
let heartRateQuery = HKAnchoredObjectQuery(type: quantityType, predicate: nil, anchor: anchor, limit: Int(HKObjectQueryNoLimit)) { (query, sampleObjects, deletedObjects, newAnchor, error) -> Void in
guard let newAnchor = newAnchor else {return}
self.anchor = newAnchor
self.updateHeartRate(sampleObjects)
嗨!你有沒有找到解決這個問題的方法? – Philip
嗨@Philip感謝您的寫作。目前還沒有解決方案。 –