PFRole Class Reference

Inherits from PFObject : NSObject
Conforms to PFSubclassing
Declared in PFRole.h

Overview

The PFRole class represents a Role on the Parse server. PFRoles represent groupings of PFUser objects for the purposes of granting permissions (e.g. specifying a PFACL for a PFObject). Roles are specified by their sets of child users and child roles, all of which are granted any permissions that the parent role has.

Roles must have a name (which cannot be changed after creation of the role), and must specify an ACL.

Creating a New Role

– initWithName:

Constructs a new PFRole with the given name. If no default ACL has been specified, you must provide an ACL for the role.

- (instancetype)initWithName:(NSString *)name

Parameters

name

The name of the Role to create.

Declared In

PFRole.h

– initWithName:acl:

Constructs a new PFRole with the given name.

- (instancetype)initWithName:(NSString *)name acl:(nullable PFACL *)acl

Parameters

name

The name of the Role to create.

acl

The ACL for this role. Roles must have an ACL.

Declared In

PFRole.h

+ roleWithName:

Constructs a new PFRole with the given name.

+ (instancetype)roleWithName:(NSString *)name

Parameters

name

The name of the Role to create.

Discussion

If no default ACL has been specified, you must provide an ACL for the role.

Declared In

PFRole.h

+ roleWithName:acl:

Constructs a new PFRole with the given name.

+ (instancetype)roleWithName:(NSString *)name acl:(nullable PFACL *)acl

Parameters

name

The name of the Role to create.

acl

The ACL for this role. Roles must have an ACL.

Declared In

PFRole.h

Role-specific Properties

  name

Gets or sets the name for a role.

@property (nonatomic, copy) NSString *name

Discussion

This value must be set before the role has been saved to the server, and cannot be set once the role has been saved.

Warning: A role’s name can only contain alphanumeric characters, _, -, and spaces.

Declared In

PFRole.h

  users

Gets the PFRelation for the PFUser objects that are direct children of this role.

@property (nonatomic, strong, readonly) PFRelation *users

Discussion

These users are granted any privileges that this role has been granted (e.g. read or write access through ACLs). You can add or remove users from the role through this relation.

Declared In

PFRole.h

  roles

Gets the PFRelation for the PFRole objects that are direct children of this role.

@property (nonatomic, strong, readonly) PFRelation *roles

Discussion

These roles' users are granted any privileges that this role has been granted (e.g. read or write access through ACLs). You can add or remove child roles from this role through this relation.

Declared In

PFRole.h