I hava a problem

hi, i am a new member to the group, sorry if i wrote wrong, first of all, i am learning swift and i ran into a problem, can you help me?I want to add 6 images into the "var" variable and I get an error. I use the code I wrote before, but it doesn't work.

imageOne.image = imageLiteral

Replies

yes sure, I need a your support

Welcome to the forum.

Some advice:

  • you get an error. Please tell what is the exact message
  • show more code so that we can understand what you are doing.

.

add 6 images into the "var" variable

Which var is this ?

You probably use an old tutorial. Don't use imageLiteral anymore.

To create an image, just call:

imageOne.image = UIImage(named: "Your image name")

If you want to put in an array of 6 images:

var myImages : [UIImage] = [] // starts empty
myImages.append(imageOne)  // Append the first image. Do the same for the 5 others.