ios - 更新查询对象上的解析 ACL

标签 ios swift xcode acl parse-server

在我的 iOS 应用程序中,我正在创建一个 PFObject 并将其保存到 Parse。后来,创建了一个用户帐户(以前不存在),并尝试修改它,但无法修改,因为 PFObjects 的 ACL 未设置为允许该用户拥有权限。如何修改 Parse 中现有对象的 ACL 以允许该用户访问?我不想想要允许公共(public)写入访问。

如果给出正确的 code 查询参数,以下代码将打印 Success!,但是当我在 Parse 中检查 ACL 时,它根本没有更新。

let query = PFQuery(className: "Bike")
query.whereKey("bikeID", equalTo: code)
query.findObjectsInBackground { (objects: [PFObject]?, error: Error?) in
    guard let obj = objects?[0], error == nil else {
        print("Error")
        return
    }
    obj.acl?.setWriteAccess(true, for: PFUser.current()!)
    obj.saveInBackground { (success: Bool, error: Error?) in
        if error != nil {
            print(error!.localizedDescription)
        }
        else {
            print("Success!")
        }
    }
}

This post似乎表明 ACL 无法通过我的应用程序的 Swift 代码进行更改。

最佳答案

如果您预先知道要授予访问权限的对象,则可以在 User 类的 CloudCode afterSave Hook 中更改其 ACL:在 afterSave,测试用户是否刚刚创建(以避免为后续保存请求重做此工作),然后查找对象并使用主 key 设置访问权限。

关于ios - 更新查询对象上的解析 ACL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48605085/

相关文章:

swift - 对象 [89368] : Class VCWeakObjectHolder is implemented in both

iphone - 升级到 Xcode 4.2/iOS 5 后类别中的方法抛出异常

ios - 使用 SDWebImage 从视频 URL 获取缩略图

swift - 我如何使用 UserDefaults 来保存和加载我的结构?

ios - IOS 5 应用程序中的多个 UIPickerView

ios - 如何在不破坏 Rust 工具链的情况下在 XCode 中测试 iOS 应用程序?

ios - 应用因违反 iCloud 存储准则而被拒绝

ios - 当应用程序处于终止模式时如何从推送通知重定向到特定的 View Controller

iphone - 如何将坐标转换为图像

objective-c - fatal error : unexpectedly found nil while unwrapping an Optional value, 快速获取 json 错误