简体   繁体   中英

Unable to retrieve image from Parse (Swift)

I've been working on this problem for almost two days now and still can't seem to figure it out. I am trying to load a saved image from Parse onto a UIImageView. I have another function that does this for two pieces of text but when I try retrieving the image, it doesn't work. Any ideas?

  func showImage() {
    var query = PFQuery(className: "Description")
    query.orderByDescending("ceatedAt")
    query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]?, error: NSError?) -> Void in

        self.images = [UIImage]()
        if let objects = objects {
            for imageObject in objects {

                let userImage = (imageObject as! PFObject)["UserPhoto"] as? PFFile
                if userImage != nil {
                    userImage!.getDataInBackgroundWithBlock {
                        (imageData, error) -> Void in


                        if error == nil {
                            let image = UIImage(data: imageData!)

                            self.images.append(image!)

                        }
                        self.theTableView.reloadData()
                    }}

            }
        }
    }
}

请尝试将以下代码行query.orderByDescending(“ ceatedAt”)更改为query.orderByDescending(“ createdAt”)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM