Reputation: 47
I am trying to call my image but it is showing this error : " Cannot assign a value of type UIImage? to a value of type Dynamic " exactly in this line "post.image1 = UIImage(data: data!, scale:1.0) " .
let postsQuery = Post.query()
postsQuery!.findObjectsInBackgroundWithBlock {(result: [AnyObject]?, error: NSError?) -> Void in
self.posts = result as? [Post] ?? []
for post in self.posts {
// 2
let data = post.imageFile?.getData()
// 3
post.image1 = UIImage(data: data!, scale:1.0)
}
// 9
self.tableView.reloadData()
}
}
Upvotes: 0
Views: 2727
Reputation: 23882
You have to unwrap like as :
if let image = UIImage(data:yourImageData) {
DispatchQueue.main.async {
self.yourImageView.image = image
}
}
Upvotes: 1