UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

(Challenge 1 for projects 1-3) Is there a way?

Forums > 100 Days of Swift

I want to put the flag images in the Assets Catalog and then read their names out at run time.

Is there a way to get a list of assets? I think there is not.

I think I am going to rename the 3x images to, say, "Estonia.jpg" and putting them in a folder as we did with StormViewer.

I wish there were a fancier solution.


No but in Xcode 15 (beta) you can use do

static let allCountries: [ImageResource] = [.estonia, .france, .germany, .ireland, .italy, .nigeria, .poland, .russia, .spain, .UK, .US]

You might have to change a few other codes to make it work!


That's nifty, but doesn't solve the problem of loading an unknown set of countries.


TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.