Yahyacode
Yahyacode

Reputation: 47

Cannot assign a value of type UIImage? to a value of type Dynamic<UIImage?>

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

Answers (1)

Ashish Kakkad
Ashish Kakkad

Reputation: 23882

You have to unwrap like as :

if let image = UIImage(data:yourImageData) {
    DispatchQueue.main.async {
         self.yourImageView.image = image
    }
}

Upvotes: 1

Related Questions