How to set ACL for PFObject in Swift?

I am using the Parse iOS SDK and I am creating objects for a specific class (not "_User"). However, I need to change the ACLs of these objects so that everyone can read or write it. Parse currently sets the ACLs of newly created objects in Public Read and Creator Write.

In short, I'm not sure how to set the ACL of a Parse object for public read / write in Swift.

+5
source share
4 answers

It has been updated, now it should be done as follows:

let acl = PFACL() acl.publicReadAccess = true acl.publicWriteAccess = true yourObject.ACL = acl 
+7
source
 let acl = PFACL() acl.setPublicReadAccess(true) acl.setPublicWriteAccess(true) yourObject.ACL = acl 

UPDATE:

You can set write permissions for a larger group of users using "roles":

 acl.setWriteAccess(true, forRoleWithName:"everyone") 

First you need to create a role.

+4
source

If you want your ACL settings to apply to all objects you create, you can:

  • Open AppDelegate.swift
  • In the didFinishLaunchingWithOptions method

    • You can see that PFACL () is set as follows:

       let defaultACL = PFACL(); // If you would like all objects to be private by default, remove this line. defaultACL.setPublicReadAccess(true) 
  • Here just add:

      defaultACL.setPublicWriteAccess(true) 
+2
source

Like in Parse iOS SDK 1.14.3:

 let acl = PFACL() acl.getPublicReadAccess = true acl.getPublicWriteAccess = true object.acl = acl 
+2
source

All Articles