ios Load a tab separated text to Dictionary and UIPickerView - ios

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

Related

Drupal8 Currency Module, How to configure in my content type and views?

I installed the Currency module in my localhost, i really in need of the currency converter dynamically.
I store the currency value in USD on my field and shown as its in my view of table format.
For Customer, view of currency drop-down will be there, if the user selects the currency the value it need to be convert from USD to AUD, AUD to NZD etc., like this.
Kindly Provide me solution whether the currency converter gets the latest exchange rate and currency value.
Need for support
If you use Coorrency - Currency Converter module ,then this is the stratergy
if you use a free service then the rates are refreshed every 30
minutes.
if you use a Premium service then the rates are refreshed every 15 minutes.

Matching MapKit Places with Facebook Places

I am saving photos with city names to server in my application. Firstly, I am getting city names with MapKit, by using latitude and longitude, and then saving photo and city name to database. Later when user want to search a photo, he/she writes the city name and I use autocomplete with Facebook Places (Graph API).
The problem is Facebook Places and MapKit might have different names (spelling). Even they are both in English. I am wondering how to query from my own server which have MapKit cities in it, with Facebook Places cities.
I assume it a is little bit more complicated as it seems first time. Until Facebook, Apple are not using the same data source for their city names it will be hard to find the cities where the name is not exactly the same if you are using the "raw" string, that you get from the FB places.
Maybe there is a much easier way to achieve it, but my first attempts would cover these options:
Save the geo points when you upload the photo, then find a library, API etc.. that returns you a latitude longtitude data based on the Facebook city name and then use this to query the closest result in your database (based on photo location)
2.
Suppose the user typed in a city name and you have a string value (call it rawCity) with the desired city name. Now rawCity should be contained in or be equal to the string that represents the city's Mapkit name.
Let's assign rawCity to a new string called searchStringCity and remove white spaces from it and make the whole string lowercase (non-ascii chars can make some trouble too).
Now you have two strings that should be added to a dictionary: /Pseudo code/
rawCity = Sample City Name
searchStringCity = yoursamplecity
fbCityDictionary = {rawName:rawCity, searchString:searchStringCity}
After you have the fbCityDictionary you're ready with the Facebook part.
As a second step you need some database related work, so next I would create a searchString column in my database and fill it with the "standarized"(remove whitespaces,uppercases,charachter coding stuff) name of the Mapkit type city name.
Now you can write a query where a db item's searchString value is equal to fbCityDictionary[searchString]. However it won't perfectly solve your problem, it will work when a whitespace or a lower/uppercase letter was the problem, but there are a lot of city names that doesn't has an english version and they can be much different in different map databases.
So you will be good for example cases like these:
Facebook version:
Sample City Name ---> samplecityname
Mapkit version:
Samplecity Name ---> samplecityname
These solutions can improve the results, but I would be curious to hear a better solution.

Currency of in-app billing transaction

I see that the response I get from Google Play after the user had purchased one of my in-app products contains the following information:
Description, ItemType, Json, Price, Sku, Title and Type
Price is a string that contains the currency and price. eg: "€1.17".
I would like to get the same price information in a more structured way and separately. Something like a three digit ISO code of the currency and the price in numeric format, without having to parse the string, which would have been ugly and unsafe.
Do you think that there is a way to do this?
Check price_amount_micros field.
Price in micro-units, where 1,000,000 micro-units equal one unit of
the currency. For example, if price is "€7.99", price_amount_micros is
"7990000".
More here: In-app Billing Reference

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.

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

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.

Resources