WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

Use the user’s preferred currency, rather than always using US dollars.

Forums > 100 Days of SwiftUI

Hi guys!Please help me with project 7


Not exactly sure where your problem lies, but the following link contains a lot of information on currency symbols and currency formatting:


As you can see, changing the currency symbol is easy. The difficulty lies in getting the formatting right.



Not sure if your are talking about the same issue I had - In one of the first projects (the tip calculator) I was using the local currency but kept getting $ - I had to change the regional settings in the phone simulator to UK before I could get £



For me, even this was not enough. I did get the right symbol, but I also wanted local formatting (thousands separator, etc). For this,I had to change the development language. See https://developer.apple.com/forums/thread/706739.


I just want let user chose currency(USD, EURO, CAD...).


To (freely) quote Obelix from another thread: Do you want the answer, or do you want to learn?

If the latter, here is something to help you on your way.

It all depends on how you read the challenge.

If all you want to do is choose the user's preferred currency symbol for him/her, (assuming you know what it is), all you have to do is review the lesson, and the answer will be staring you in the face. This is how I understood the challenge, and it is really easy to do.

(Do you perhaps copy the code from the lesson into your project? Then the solution would be easy to miss. Or do you enter it manually? You should!)

If, however, you read the challenge as: Let the user choose the currency symbol while using the app, then you will need to create some dialog. Ask yourself: How would that look like? Maybe you want to let the user choose from a list you provide. What type of view do you know that allows you to do that? Or maybe you want to do it differently. It is up to you.

Good luck.


Hacking with Swift is sponsored by Fernando Olivares

SPONSORED Fernando's book will guide you in fixing bugs in three real, open-source, downloadable apps from the App Store. Learn applied programming fundamentals by refactoring real code from published apps. Hacking with Swift readers get a $10 discount!

Read the book

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.