繁体   English   中英

试图从parse.com检索图像但出现错误

[英]trying to retrieve image from parse.com but getting error

   func loadImages() {

    var query = PFQuery(className: "CollegeCover")

    query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in

        if (error == nil) {

            let imageObjects = objects! as [PFObject]

            for object in objects! {

                let thumbNail = object["image"] as! PFFile


                thumbNail.getDataInBackgroundWithBlock{ (objects, error) -> Void in

                    if (error == nil) {

                        let imageObjects = objects as? [NSData?]


                        let image = UIImage(data:objects!)

                        self.userImageView.image = image
                        print(image)
                    }}}

        }
        else{
            print("Error in retrieving \(error)")
        }

    }//findObjectsInBackgroundWithblock - end


     }

我正在尝试检索存储在parse.com服务器中的图像,但我不知道为什么会出错,并且不确定我获取图像的方法是否正确,因此如果有人知道如何请帮助我正确地做,或者错误所遗漏的或做错的是

致命错误:解开可选值(lldb)时意外发现nil

我可能是错的,但我认为您得到nil结果的唯一原因是因为您使用了不正确的列名,即“ image”。 您确定这是您在Parse中的列的确切名称吗?

克服该错误后,由于代码看起来还可以,因此应该可以使图像加载良好。 但是,您也可以考虑使用PFImageView,从而省去了额外编码的麻烦,因为您可以为其文件属性指定PFFile对象。 请参阅此处的示例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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