如何使用 Parse findObjectsInBackground 获取 objectID

How to use Parse findObjectsInBackground to get objectID

我成功地从 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
            }

您可以像这样检索 objectId

let imageId = object.objectId