user3892914
user3892914

Reputation:

Parse, getting pointer objects stored in an array along with primary object query

i have a "Station" object, it contains a column named "imagePointers", the array is populated as such:

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

The pointers point at another object named Image, but they are stored as an array at the station object.

In iOS i query the station object as such:

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

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

return query;

When i receive the station object, the imagePointers field is empty? Completely empty

Upvotes: 1

Views: 1017

Answers (1)

race_carr
race_carr

Reputation: 1377

It seems like what you're trying to do is not supported by Parse.com. See this question.
Something like this might get you part of the way there. I'm using PFFiles to store images and then using the URL for the PFFile to load them in UIImageView with 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];
    }

Upvotes: 1

Related Questions