嵌套选择查询缺少指针和className - Parse.com

时间:2015-11-20 08:55:59

标签: ios parse-platform

当我执行仅请求指针的某些选定字段的查询时,收到的响应不包括指针类型和类名。

示例:

PFQuery * query = [PFQuery queryWithClassName:@"ClassA"];
[query includeKey:@"column1"]; // This is a pointer with classname : ClassB
[query selectKeys:@[@"column1.subColumn1",@"column1.subColumn2"]];

结果是

"column1": {
        "createdAt": "2015-10-29T19:46:17.167Z",
        "subColumn1": "Some Value1",
        "subColumn2": "Some Value2",
        "objectId": "iCK9CpgKAh",
        "updatedAt": "2015-11-16T14:30:11.312Z"
      },

但是,如果我不只是选择一些字段,并包含所有子列字段,它将起作用:

PFQuery * query = [PFQuery queryWithClassName:@"ClassA"];
[query includeKey:@"column1"]; // This will select all fields inside column1

结果:

"column1": {
        "__type": "Pointer",
        "className": "ClassB",
        "createdAt": "2015-10-29T19:46:17.167Z",
        "subColumn1": "Some Value1",
        "subColumn2": "Some Value2",
        "subColumn3": "Some Value3",
        "objectId": "iCK9CpgKAh",
        "updatedAt": "2015-11-16T14:30:11.312Z"
      },

当我们使用PFSubclassing时会产生问题,因为指针列不被视为指针,而是被视为NSDictionary

例如:

PFClassAPFClassB是解析子类。

@interface PFClassB : PFObject<PFSubclassing>
@property (copy) NSString * subColumn1;
@property (copy) NSString * subColumn2;
@property (copy) NSString * subColumn2;
@end

@interface PFClassA : PFObject<PFSubclassing>
@property (strong) PFClassB * column1;
@end

当我们执行查询时,只需选择PFClassB的2个字段,如上面的查询, column1的结果将是字典,而不是PFClassB。

有解决方法吗?

感谢。

0 个答案:

没有答案