如何从Parse.com获取单个键的所有值 [英] How to fetch all values for a single key from Parse.com
问题描述
我正试图从Parse的PeopleName
类中获取所有名称.它没有显示任何构建错误,但出现运行时错误Error: field Name cannot be included because it is not a pointer to another object (Code: 102, Version: 1.2.17)
.
I'm trying to fetch all the names from my PeopleName
class from Parse. It's not showing any build error, but I get a runtime error Error: field Name cannot be included because it is not a pointer to another object (Code: 102, Version: 1.2.17)
.
这是代码.有帮助吗?
PFQuery *query = [PFQuery queryWithClassName:@"PeopleNames"];
[query includeKey:@"Name"];
[query selectKeys:@[@"Name"]];
[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
for (PFObject *object in results) {
[self.boyNames addObject:[object objectForKey:@"Name"]];
}
}];
推荐答案
[query selectKeys:@[@"Name"]];
正确,以将返回的数据限制为仅名称.不需要[query includeKey:@"Name"];
,因为它是将目标对象包括在关系的另一端(您没有)的方法.
[query selectKeys:@[@"Name"]];
is correct to limit the returned data to only the names. [query includeKey:@"Name"];
is not required as it is the way to include the destination objects at the other end of a relationship (which you don't have).
因此,保留[query selectKeys:@[@"Name"]];
并删除[query includeKey:@"Name"];
,您会得到想要的东西.
So, keep [query selectKeys:@[@"Name"]];
and remove [query includeKey:@"Name"];
and you'll get what you want.
这篇关于如何从Parse.com获取单个键的所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!