TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

(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.

3      

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!

4      

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

3      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

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.