Reputation: 271
I've created an array of UIimages inside of a structure. Now im trying to display the image and i get this error:
Cannot assign a value of type '[UIImage]' to a value of type 'UIImage?
"primeiraImagem.image" is an Outlet.
Here is the structure:
I'm stuck here and i cant solve this =/
Thank you :)
Upvotes: 0
Views: 5318
Reputation: 11555
Cannot assign a value of type '[UIImage]' to a value of type 'UIImage?
restaurante.imagem is an array [UIImage]
. In order to assign one image from it to an UIImage
, you need to select only one image from the array. For example this code gets the first and makes sure that the assignment takes place only if the array is not empty:
if let image = restaurante.imagem.first {
primeiraImagem.image = image
}
Upvotes: 5