Reputation: 6861
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
}
Upvotes: 0
Views: 1353
Reputation: 801
imageFromParse!.getDataInBackgroundWithBlock(..)
I recommend you to use PFImageView to load files, especially when you load images for cell or you will have a problem with canceling loading image, as your cell are reusing.
You still should use the check for optional value: if let imageNews = .. , in case your object are not loaded.
if let imageNews = object.objectForKey("imageNews") as? PFFile {
cell!.imageView.image = UIImage(named: "placeholder.jpg")
cell!.imageView.file = thumbnail
}
You can find more here: http://blog.parse.com/learn/engineering/loading-remote-images-stored-on-parse/
Upvotes: 0
Reputation: 6861
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
})
Upvotes: 1