PFRelation

Objective-C

@interface PFRelation<ObjectType : PFObject *> : NSObject

Swift

class PFRelation<ObjectType> : NSObject where ObjectType : PFObject

The PFRelation class that is used to access all of the children of a many-to-many relationship. Each instance of PFRelation is associated with a particular parent object and key.

  • The name of the class of the target child objects.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSString *targetClass;

    Swift

    var targetClass: String? { get set }

Accessing Objects

  • Returns a PFQuery object that can be used to get objects in this relation.

    Declaration

    Objective-C

    - (nonnull PFQuery<ObjectType> *)query;

    Swift

    func query() -> PFQuery<ObjectType>

Modifying Relations

  • Adds a relation to the passed in object.

    Declaration

    Objective-C

    - (void)addObject:(nonnull ObjectType)object;

    Swift

    func add(_ object: ObjectType)

    Parameters

    object

    A PFObject object to add relation to.

  • Removes a relation to the passed in object.

    Declaration

    Objective-C

    - (void)removeObject:(nonnull ObjectType)object;

    Swift

    func remove(_ object: ObjectType)

    Parameters

    object

    A PFObject object to add relation to.