如何使用解析findObjectsInBackground获取对象ID

问题描述 投票:0回答:1

我正在成功地从Parse服务器保存/检索图像,但是当我尝试获取objectID时,我的代码崩溃了。我应该如何获取objectId以供将来参考,例如删除对象?

let query = PFQuery(className: "Images")

    query.findObjectsInBackground {
        (objects:[PFObject]?, error: Error?) -> Void in

        if error == nil && (objects != nil) {
            for object in objects! {

                let imageFile = object["imageFileObject"] as! PFFileObject
                let imageWidth = object["imageWidth"] as! CGFloat
                let imageName = object["imageName"] as! String
                let imageId = object["objectId"] as! String  // CRASHES ON THIS LINE
            }
parse-platform parse-server
1个回答
0
投票

您可以像这样检索objectId

let imageId = object.objectId
© www.soinside.com 2019 - 2024. All rights reserved.