Sort HKQuantitySample by Quantity
Originator: | konstantin.koval1 | ||
Number: | rdar://22068394 | Date Originated: | 30-Jul-2015 10:33 AM |
Status: | Open | Resolved: | |
Product: | Developer Tools | Product Version: | Xcode 6.4 (6E35b) |
Classification: | Feature (New) | Reproducible: | Always |
Summary: I want to order HKQuantitySample by the Quantity when execute HKSampleQuery. I want something similar as HKPredicateKeyPathQuantity key The problem: I want to fetch only few items, set a limit with the highest value, but I can't sort them by value. To make it work now I need to fetch all the items to the memory and sort them manually. Code Example: let type = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeight) let sort = [ NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: true), NSSortDescriptor(key: HKSampleSortIdentifierEndDate, ascending: true), //I want one more Sort Item here :( //NSSortDescriptor(key: HKSampleSortIdentifierQuantity, ascending: true) ] let query = HKSampleQuery(sampleType: type, predicate: nil, limit: 2, sortDescriptors: sort) { query, res, error in completion(res, error) } healthKit.executeQuery(query) Solution: Add HKSampleSortIdentifierQuantity
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!