Alexsander Alexsander - 3 months ago 6
iOS Question

How to load file(it is image) from parse in swift ios application?

How to load file(it is image) from www.parse.com in swift ios application? I tried as stated on the parse.com but does not work. There is an error "'PFFile?' is not convertible to 'StringLiteralConvertible'". Please tell me how to upload multiple images.

if let imageNews = object["imageNews"] as? PFFile {
cell!.imageView.image = UIImage(named: "placeholder.jpg")
cell!.imageView.file = thumbnail
}

Answer

I found a solution of my error. This is below. Thank everybody.

  var imageFromParse = object?.objectForKey("imageNews") as? PFFile
        imageFromParse!.getDataInBackgroundWithBlock({ (imageData: NSData?, error: NSError?) -> Void in
            var image: UIImage! = UIImage(data: imageData!)!
            cell?.imageViewCell?.image = image
        })