首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从healthkit查询中排除自己的样本

从healthkit查询中排除自己的样本
EN

Stack Overflow用户
提问于 2014-11-17 00:58:40
回答 1查看 462关注 0票数 1

我正在写一个应用程序,在其他事情中,从HealthKit读取体重样本。

我也在写样本。

我正在尝试读取不属于我的最新样本:

代码语言:javascript
复制
NSPredicate* non_fdct = [NSCompoundPredicate notPredicateWithSubpredicate:[HKQuery predicateForObjectsFromSource:[HKSource defaultSource]]];
NSSortDescriptor *last = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate ascending:NO];
HKSampleQuery* query = [[HKSampleQuery alloc] initWithSampleType:[HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass] predicate:non_fdct limit:1 sortDescriptors:@[last] resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {  ... };

但如果是最新的样品,我会自己去拿的。

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2014-11-26 05:43:21

您构造non_fdct谓词的方式不太正确。试着这样做:

NSPredicate *non_fdct = [NSPredicate predicateFromString:@"%K != %@", HKPredicateKeyPathSource, [HKSource defaultSource]];

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26959565

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档