我需要在Parse中设置一个ACL,但我不知道将代码放在哪里。
目标C中的代码如下:

PFUser *user = [PFUser currentUser];

user.ACL = [PFACL ACLWithUser:user];

我把这个放哪儿?还有,有人知道怎么把这个翻译成swift吗?
如有任何关于如何进行的建议,我们将不胜感激。

最佳答案

我之前在Swift的parse上为一个userphoto类做了这个。这是用户选择新图像时调用的func中的代码。acl部分在第4行:

var userPhoto = PFObject(className: "UserPhoto")
//imageFile is NSData passed to func
userPhoto.setObject(imageFile, forKey: "imageFile")
userPhoto.ACL = PFACL(user: PFUser.currentUser())
userPhoto.setObject(PFUser.currentUser(), forKey: "user")
//save
userPhoto.saveInBackgroundWithBlock({ (success, error) -> Void in
    println("Saved new userPhoto to Parse")
})

希望有帮助!

08-28 16:14