Reputation:
What is the updated code to upload user profileImage, I got an error trying to update user profileImage.
How do I fix this error?
Cannot invoke initializer for type 'UIImage' with an argument list of type '(@escaping () -> ())'
self.ProfileImage.image = UIImage{data; data!}
Upvotes: 0
Views: 217
Reputation: 157
There are few issues with your code such as you are using {} instead of () . So , the code will actually look like ...
self.ProfileImage.image = UIImage(data: data!)
but since data is optional value , it can come as nil if not handled properly. This will lead to crash within your app . So use optional binding in such cases to check whether the data variables actually contain any values , like the code below.
if let imageData = data{
self.ProfileImage.image = UIImage(data: imageData)
}else{
self.ProfileImage.image = UIImage(named : "image_when_no_value_is_present")
}
Upvotes: 0
Reputation: 5225
You are using { braces } whereas you need to use ( round brackets )
myImageView.image = UIImage(data: imageData)
Upvotes: 1