Aboodnet
Aboodnet

Reputation: 143

Access all images in Assets.xcassets ?? [ SWIFT 3 ]

I have some image sets located in Assets.xcassets folder/library, as shown in the screenshot below. All what i want is to add those images to an array so i can use it later on to populate a CollectionView cells. How can i insert those images into an array?

For example, the array should include [airplace.jpg, cars.jpg, ship.jpg]

enter image description here

Upvotes: 1

Views: 2158

Answers (1)

matt
matt

Reputation: 534950

Well, the way you retrieve an image from the asset catalog is with UIImage(named:). So... How about:

let theArray = [UIImage(named:"airplane")!, 
                UIImage(named:"cars")!, 
                UIImage(named:"ship")!]

Upvotes: 1

Related Questions