PFACL Class Reference

Inherits from NSObject
Conforms to NSCoding
NSCopying
Declared in PFACL.h

Overview

The PFACL class is used to control which users can access or modify a particular object. Each PFObject can have its own PFACL. You can grant read and write permissions separately to specific users, to groups of users that belong to roles, or you can grant permissions to “the public” so that, for example, any user could read a particular object but only a particular set of users could write to that object.

Creating an ACL

+ ACL

Creates an ACL with no permissions granted.

+ (instancetype)ACL

Return Value

Returns a new PFACL.

Declared In

PFACL.h

+ ACLWithUser:

Creates an ACL where only the provided user has access.

+ (instancetype)ACLWithUser:(PFUser *)user

Parameters

user

The user to assign access.

Declared In

PFACL.h

Controlling Public Access

  publicReadAccess

Controls whether the public is allowed to read this object.

@property (nonatomic, assign, getter=getPublicReadAccess) BOOL publicReadAccess

Declared In

PFACL.h

  publicWriteAccess

Controls whether the public is allowed to write this object.

@property (nonatomic, assign, getter=getPublicWriteAccess) BOOL publicWriteAccess

Declared In

PFACL.h

Controlling Access Per-User

– setReadAccess:forUserId:

Set whether the given user id is allowed to read this object.

- (void)setReadAccess:(BOOL)allowed forUserId:(NSString *)userId

Parameters

allowed

Whether the given user can write this object.

userId

The [PFObject objectId] of the user to assign access.

Declared In

PFACL.h

– getReadAccessForUserId:

Gets whether the given user id is explicitly allowed to read this object. Even if this returns NO, the user may still be able to access it if getPublicReadAccess returns YES or if the user belongs to a role that has access.

- (BOOL)getReadAccessForUserId:(NSString *)userId

Parameters

userId

The [PFObject objectId] of the user for which to retrive access.

Return Value

YES if the user with this objectId has explicit read access, otherwise NO.

Declared In

PFACL.h

– setWriteAccess:forUserId:

Set whether the given user id is allowed to write this object.

- (void)setWriteAccess:(BOOL)allowed forUserId:(NSString *)userId

Parameters

allowed

Whether the given user can read this object.

userId

The objectId of the user to assign access.

Declared In

PFACL.h

– getWriteAccessForUserId:

Gets whether the given user id is explicitly allowed to write this object. Even if this returns NO, the user may still be able to write it if getPublicWriteAccess returns YES or if the user belongs to a role that has access.

- (BOOL)getWriteAccessForUserId:(NSString *)userId

Parameters

userId

The [PFObject objectId] of the user for which to retrive access.

Return Value

YES if the user with this objectId has explicit write access, otherwise NO.

Declared In

PFACL.h

– setReadAccess:forUser:

Set whether the given user is allowed to read this object.

- (void)setReadAccess:(BOOL)allowed forUser:(PFUser *)user

Parameters

allowed

Whether the given user can read this object.

user

The user to assign access.

Declared In

PFACL.h

– getReadAccessForUser:

Gets whether the given user is explicitly allowed to read this object. Even if this returns NO, the user may still be able to access it if getPublicReadAccess returns YES or if the user belongs to a role that has access.

- (BOOL)getReadAccessForUser:(PFUser *)user

Parameters

user

The user for which to retrive access.

Return Value

YES if the user has explicit read access, otherwise NO.

Declared In

PFACL.h

– setWriteAccess:forUser:

Set whether the given user is allowed to write this object.

- (void)setWriteAccess:(BOOL)allowed forUser:(PFUser *)user

Parameters

allowed

Whether the given user can write this object.

user

The user to assign access.

Declared In

PFACL.h

– getWriteAccessForUser:

Gets whether the given user is explicitly allowed to write this object. Even if this returns NO, the user may still be able to write it if getPublicWriteAccess returns YES or if the user belongs to a role that has access.

- (BOOL)getWriteAccessForUser:(PFUser *)user

Parameters

user

The user for which to retrive access.

Return Value

YES if the user has explicit write access, otherwise NO.

Declared In

PFACL.h

Controlling Access Per-Role

– getReadAccessForRoleWithName:

Get whether users belonging to the role with the given name are allowed to read this object. Even if this returns NO, the role may still be able to read it if a parent role has read access.

- (BOOL)getReadAccessForRoleWithName:(NSString *)name

Parameters

name

The name of the role.

Return Value

YES if the role has read access, otherwise NO.

Declared In

PFACL.h

– setReadAccess:forRoleWithName:

Set whether users belonging to the role with the given name are allowed to read this object.

- (void)setReadAccess:(BOOL)allowed forRoleWithName:(NSString *)name

Parameters

allowed

Whether the given role can read this object.

name

The name of the role.

Declared In

PFACL.h

– getWriteAccessForRoleWithName:

Get whether users belonging to the role with the given name are allowed to write this object. Even if this returns NO, the role may still be able to write it if a parent role has write access.

- (BOOL)getWriteAccessForRoleWithName:(NSString *)name

Parameters

name

The name of the role.

Return Value

YES if the role has read access, otherwise NO.

Declared In

PFACL.h

– setWriteAccess:forRoleWithName:

Set whether users belonging to the role with the given name are allowed to write this object.

- (void)setWriteAccess:(BOOL)allowed forRoleWithName:(NSString *)name

Parameters

allowed

Whether the given role can write this object.

name

The name of the role.

Declared In

PFACL.h

– getReadAccessForRole:

Get whether users belonging to the given role are allowed to read this object. Even if this returns NO, the role may still be able to read it if a parent role has read access.

- (BOOL)getReadAccessForRole:(PFRole *)role

Parameters

role

The name of the role.

Return Value

YES if the role has read access, otherwise NO.

Discussion

The role must already be saved on the server and it’s data must have been fetched in order to use this method.

Declared In

PFACL.h

– setReadAccess:forRole:

Set whether users belonging to the given role are allowed to read this object.

- (void)setReadAccess:(BOOL)allowed forRole:(PFRole *)role

Parameters

allowed

Whether the given role can read this object.

role

The role to assign access.

Discussion

The role must already be saved on the server and it’s data must have been fetched in order to use this method.

Declared In

PFACL.h

– getWriteAccessForRole:

Get whether users belonging to the given role are allowed to write this object. Even if this returns NO, the role may still be able to write it if a parent role has write access.

- (BOOL)getWriteAccessForRole:(PFRole *)role

Parameters

role

The name of the role.

Return Value

YES if the role has write access, otherwise NO.

Discussion

The role must already be saved on the server and it’s data must have been fetched in order to use this method.

Declared In

PFACL.h

– setWriteAccess:forRole:

Set whether users belonging to the given role are allowed to write this object.

- (void)setWriteAccess:(BOOL)allowed forRole:(PFRole *)role

Parameters

allowed

Whether the given role can write this object.

role

The role to assign access.

Discussion

The role must already be saved on the server and it’s data must have been fetched in order to use this method.

Declared In

PFACL.h

Setting Access Defaults

+ setDefaultACL:withAccessForCurrentUser:

Sets a default ACL that will be applied to all instances of PFObject when they are created.

+ (void)setDefaultACL:(nullable PFACL *)acl withAccessForCurrentUser:(BOOL)currentUserAccess

Parameters

acl

The ACL to use as a template for all instance of PFObject created after this method has been called. This value will be copied and used as a template for the creation of new ACLs, so changes to the instance after this method has been called will not be reflected in new instance of PFObject.

currentUserAccess
  • If YES, the PFACL that is applied to newly-created instance of PFObject will provide read and write access to the [PFUser currentUser] at the time of creation.
  • If NO, the provided acl will be used without modification.
  • If acl is nil, this value is ignored.

Declared In

PFACL.h