Question: What way is more convenient to set image from my app assets in my app Image View? I have two ways: the first one is function UIImage(named: String) or UIImage and both is working for me, but I want to know which one is the best ,so I can use one in the future

here is two examples 

```
//  first

 let myImages1 = ["dice1", "dice2", "dice3", "dice4", "dice5", "dice6"]

 @IBOutlet weak var diceImageView1: UIImageView!

 diceImageView1.image = UIImage(named: myImages1[index1])

// second

 let myImages2 = [ image1, image2, image3, image4, image5, image6 ]

 @IBOutlet weak var diceImageView2: UIImageView!

 diceImageView2.image = myImages2[index2]

```

Answer: 
We're using Images from assets catalog instead String names. It's the better way to set UIImage. But from swift 4.2 we can't use asset names anymore.
We should use image literal.
Here's the example:

```
let logoImageView: UIImageView = {
    let iv = UIImageView()

    // Set image with image literal
    iv.image = #imageLiteral(resourceName: "feedback")
    return iv
}()

```

Look at the screenshot below.

[![enter image description here](https://i.stack.imgur.com/zg0rq.png)](https://i.stack.imgur.com/zg0rq.png)

After you've typed `Image Literal` you can double click on that and choose your image from assets catalog. Here is the screenshot.

[![enter image description here](https://i.stack.imgur.com/E34hI.png)](https://i.stack.imgur.com/E34hI.png) 

But last time I use this lib R.swift. Get strong typed, autocompleted resources like images, fonts and segues in Swift projects. 

How it looks in code: 

[![enter image description here](https://i.stack.imgur.com/Rd8rJ.png)](https://i.stack.imgur.com/Rd8rJ.png)
You can create an extension for UIImage and have static variables holding your images.

```
extension UIImage {
    static var dice1: UIImage? {
        return UIImage(named: "dice1")
    }
}

let imageView = UIImageView()
imageView.image = UIImage.dice1

```

Or you can use image literals in Xcode which are nice because you can see the actual image[![ImageLiteral](https://i.stack.imgur.com/I7JHn.png)](https://i.stack.imgur.com/I7JHn.png)