简体   繁体   English

如何从Parse.com获取单个键的所有值

[英]How to fetch all values for a single key from Parse.com

I'm trying to fetch all the names from my PeopleName class from Parse. 我试图从Parse的PeopleName类中获取所有名称。 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) . 它没有显示任何构建错误,但出现运行时错误Error: field Name cannot be included because it is not a pointer to another object (Code: 102, Version: 1.2.17)

Here is code. 这是代码。 Any help? 有什么帮助吗?

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"]]; 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). 不需要,因为这是将目标对象包括在关系的另一端的方法(您没有)。

So, keep [query selectKeys:@[@"Name"]]; 因此,保留[query selectKeys:@[@"Name"]]; and remove [query includeKey:@"Name"]; 并删除[query includeKey:@"Name"]; and you'll get what you want. 您将得到想要的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM