I want to handle multiple currency formats in a textField which accepts a currency entry. Example: $13,245.12
If the user enters this value as the string: "13245.12" then converting it to a double works fine. However, if the user enters "13,245.12" the conversion to Double results in 'nil'.
If the original entry is "13245.12" and after conversion to a Double and then application of the NumberFormatter() we get "$13,245.12" as expected. However if the user needs to edit the value to "$13,555.12" then this value again gets converted to 'nil' when we attempt to get a Double.
Although its easy enough to remove the $ and , in code we still have an issue if we use the same code for other language formats unless we have language specific code - which seems to defeat the whole purpose of the NumberFormatter(). What is the best practice since this seems like a pretty basic issue regarding Localization for Apps that accept currency values?
If the user enters this value as the string: "13245.12" then converting it to a double works fine. However, if the user enters "13,245.12" the conversion to Double results in 'nil'.
If the original entry is "13245.12" and after conversion to a Double and then application of the NumberFormatter() we get "$13,245.12" as expected. However if the user needs to edit the value to "$13,555.12" then this value again gets converted to 'nil' when we attempt to get a Double.
Although its easy enough to remove the $ and , in code we still have an issue if we use the same code for other language formats unless we have language specific code - which seems to defeat the whole purpose of the NumberFormatter(). What is the best practice since this seems like a pretty basic issue regarding Localization for Apps that accept currency values?