Working with localized numbers – NSNumberFormatter Swift 2

In my case, I’m working on a csv importer and I wanted to get from the system the decimal and thousand delimiters. 

This is the way I do it, a workaround sure but works great:

var thousandDelimiter = NSNumberFormatter.localizedStringFromNumber(NSNumber(double: 1234), numberStyle: NSNumberFormatterStyle.DecimalStyle)


thousandDelimiter = thousandDelimiter.substringWithRange(thousandDelimiter.startIndex.advancedBy(1)…thousandDelimiter.startIndex.advancedBy(1))


 

var commaDelimiter = NSNumberFormatter.localizedStringFromNumber(NSNumber(double: 1.02), numberStyle: NSNumberFormatterStyle.DecimalStyle)

 

commaDelimiter = commaDelimiter.substringWithRange(commaDelimiter.startIndex.advancedBy(1)…commaDelimiter.startIndex.advancedBy(1))


Again, documentation in this case is quite good, find more here

Marc

Surviving in the App Store

Great article on the challenges of a small company in the App Store. Must read:

http://www.theverge.com/2016/3/2/11140928/app-store-economy-apple-android-pixite-bankruptcy

 

Marc