Parse (iOS): Set custom class pointer property

| | August 8, 2015

If I have a custom class in Parse, and I have the subclasses in xcode, how do I make the property for a pointer?

For example, this is how you would do it for a file and for a number:

@property (retain) PFFile *imagefile;
@property (retain) NSNumber *rank;

Classes in Parse dashboard:

Class 1: name (string), imagefile (file)

Class 2: imageid (Pointer (Class 1 row))

One Response to “Parse (iOS): Set custom class pointer property”

  1. Bojan Dimovski on November 30, -0001 @ 12:00 AM

    If you have a Parse pointer for example a Parse class named Article, then first you have to have it subclassed in Objective-C (name it Article) and add the property to your containing class like:

    @property (retain) Article *article;


    The Class2 property would look like this:

    @property (retain) Class1 *image;

    When you fetch a Class2 query, you can include the key for image, so you can load both the parent and the image row at once:

    PFQuery *query = [Class2 query];
    // Include the image data
    [query includeKey:@"image"];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
          Class2 *firstRow = [objects firstObject];
          NSLog(@"Image URL %@", firstRow.image.imagefile.url);
          // ...

Leave a Reply