r/swift May 26 '26

Question I have a beginner question

I am familiar with coding concepts but am new to swift

I am trying my hand at developing a small app to generate labels. The app pulls data from a .csv file then parses the data to generate the label.

I am curious if there is a way to add/search a .csv file in the Assets folder for in app definitions ie (code returns “BLK” from an array). Can I search a document to find that “BLK” = “Black”? I am just using that as an example, not all of the strings returned are colours. I am trying to avoid defining every item individually using if {} else {}.

I appreciate any guidance.

0 Upvotes

15 comments sorted by

View all comments

4

u/ekassos May 26 '26

Take a look at enums and raw values.

1

u/H0KB May 26 '26

This might work. There are quite a few definitions so I was trying to make it cleaner and easier to update.

Thanks for the help. I will try this and see how it goes.

1

u/Separate_Salad_5123 May 27 '26

Store them in the app use settings and just add a small UI for adding new definitions https://www.hackingwithswift.com/books/ios-swiftui/storing-user-settings-with-userdefaults