How can I let the user choose a currency to use in an iOS app? - ios

I have an app in which I let the user add products and set a price for them. Now I want to let the user choose the currency for these prices. How do I do that? I mean, should I make a custom list of all currencies, then associate these with a proper locale, which I then can send to NSNumberFormatter, or is there some better way?

Depending on what you want to display to users, creating your own configuration could be best. You can also query NSLocale to get the availableLocaleIdentifiers which you could display (or use to filter your custom list to locales the system understands). Setting the locale of the number formatted is much better and more reliable than trying to specify your own formats.

Related

How to replace gclid to custom parameter

How do I change google ads gclid to a customer parameter:
Example: https://example.com/search/coffee+maker&c=1122&g=3344
when user comes from country "A" will show the above url and for country "B" will charge the c and g number only.I mean for every country the c & g number will be unique.
You can set custom parameters using the CustomParameter mapping. This can be used in the URL like this.
If you want to remove the gclid as well you can do this by disabling autotagging, although I wouldn't recommend this as it would impact Google Analytics and conversion tracking. You can have the gclid and the custom parameters working in parallel

Does the here.com autosuggest API allow for restricting results to only cities?

I'm playing around with the Here.com autosuggest feature, and I'm trying to find a way to limit the results of a query to only cities. I only want it to return potential city, state/prov, country matches, and not addresses or specific places.
The use case here is to allow the user to start typing in their current city and have autosuggest fill out the rest. So in this case, I also can't send the query with a bounding parameter like at or in, since I want the search to allow for matches world wide.
Is this possible with the current implementation of autosuggest? Or is there another way to accomplish this?
Thanks!
The API itself doesn't allow you to limit based on city but you can select responses where localityType=city in your application.

Address field validation for iOS / Mac

I want to create an "Add Address" view, a very basic "Street, City, Zip, Country" type of page: multiple text fields inside a table view. This is simple if you only ever added U.S addresses, but I'm not sure about how to do this the right way though, handling all international use-cases as well. Essentially:
1. How do you pick the right field label for each country? For e.g. for US / Australian addresses, the field should be called "State"; for UK, it's called "County", in some places it's called "Province". How do you know what the label should say (short of hard-coding logic myself for each country)?
2. How do you validate the values for those field? UK postal codes have a certain format, whereas in the US it's a 5-digit ZIP code. Also, in the US, there is a list of states that the user can select. How do you get that list?
I've looked into NSLocale, and can't find any way to do this. Surely there must be a good and easy way to do this?
I dug around and in the end the best thing I found was a guide on "The good international address field form", but it'll still be hard to validate it. I don't think it's done.
http://www.uxmatters.com/mt/archives/2008/06/international-address-fields-in-web-forms.php
One method could be to reverse lookup the address through mapkit.
You can try to simplify the UI by adding just one text field and ask user to enter his address in an arbitrary way, and then use CLGeocoder class to convert the string to instance of CLPlacemark, which is a convenient container for such information as country, postal code, etc.

ios Load a tab separated text to Dictionary and UIPickerView

I am trying to implement a UiPickerView which will show the currency name and its symbol.
For example: United Stated of America, Dollars $
I have an entire list of 406 currency names containing the currency identifier, currency name and symbol which is tab seperated:
USD United Stated of America, Dollars $
VND Vietnam, Dong ₫
I don't want to show the identifier to the user, just the name and symbol. I plan to use the identifier for use in the code.
My questions are
What is the best way to store all the 406 currencies within the app. Is using the AppName-Prefix.pch useful for this? Or should I use a plist?
How should I load all these currencies in a dictionary with the identifier as the key?
I don't think loading each and every identifier using code will be an efficient way?
Instead of using this way of showing all currencies to the user, is there any better way from the Apple or 3rd party API which provides us a list of all the currencies in circulation?
Just showing all the currency options to the user to select one seems like too much work...
Apple should include another Picker view just like they have for Date Picker which is just for currencies.
One way to go about this is using CoreData.
Save all of them in Data Base,with the currencyList as entity and currencyName, Country, Currency ID as Attributes. perform a fetch request when user performs a query. Display just the required currency details

Rails Telephone field like a date field?

I using devise to allow users to register on my website. I have field for them to put in their telephone number when registering.
I however want to split the telephone field into 3 parts so you put in different parts of the number, kind of like a date.
Is it possible in rails to do something similar like you would with a date? When you have a date select on a form it gives the field names:
model[date(1i)]
model[date(2i)]
model[date(3i)]
Is this possible with other fields?
Cheers
I do not believe it is possible to cajole the date_select/select_date family into doing what you want.
You could try to mirror the DateTimeSelector class for your purposes: https://github.com/rails/rails/blob/master/actionpack/lib/action_view/helpers/date_helper.rb
But why not just deal with this in the controller? You can slice and dice the input any way you want. If it's a one-time thing, I would do it that way. Otherwise, it might be worth your time to solve the problem in general, in which case you can make a gem for the world to use... although I think these 'i' suffixes are only useful for dates and times as far as ActiveRecord is concerned.

Resources