解析,将指针对象与主对象查询一起存储在数组中

时间:2014-07-31 14:42:54

标签: ios parse-platform

我有一个" Station"对象,它包含一个名为" imagePointers"的列,数组填充如下:

[{"__type":"Pointer","className":"Image","objectId":"4Xtj32BOQy"},{"__type":"Pointer","className":"Image","objectId":"7DHCt7cx0O"}]

指针指向另一个名为Image的对象,但它们作为数组存储在工作站对象中。

在iOS中,i查询工作站对象:

PFGeoPoint *geoPoint = [PFGeoPoint geoPointWithLatitude:coordinate.latitude
                                              longitude:coordinate.longitude];
[query whereKey:@"location" nearGeoPoint: geoPoint];
[query includeKey:@"imagePointers.Image"];

//[query orderByDescending:@"createdAt"];

return query;

当我收到电台对象时,imagePointers字段为空?完全清空

1 个答案:

答案 0 :(得分:1)

Parse.com似乎不支持您尝试做的事情。见question 这样的事情可能会让你成为那里的一部分。我正在使用PFFiles来存储图像,然后使用PFFile的URL将它们加载到UIImageView中,并使用AFNetworking category

[query includeKey:@"imagePointers"];
[query findObjectsInBackgroundWithBlock:^(NSArray *stations, NSError *error) {
  NSArray *imagePointers = stations[0][@"imagePointers"];
  for (PFObject *images in imagePointers) {
    [image fetchIfNeeded];
    // add image to local array or something
  }
}];

  // it's possible you might need to do something like this...
  PFObject *station = stations[0];       
  [station fetchInBackgroundWithBlock:^(PFObject object, NSError error) {
    NSArray *imagePointers = stations[@"imagePointers"];
    for (PFObject *images in imagePointers) {
      [image fetchIfNeeded];
    }