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.

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      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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.