Skip to content

Instantly share code, notes, and snippets.

@sclark39
Created February 21, 2017 17:18
Show Gist options
  • Save sclark39/6d15f8acf0f690f0b4b9d1708199e79a to your computer and use it in GitHub Desktop.
Save sclark39/6d15f8acf0f690f0b4b9d1708199e79a to your computer and use it in GitHub Desktop.
What's in a name?
class Utility
{
public class func _________( ___ ____: String ) -> Decimal?
{
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.locale = Locale(identifier: "en_US")
if let number = formatter.number(from:____)
{
return number.decimalValue
}
return nil
}
public class func _________( ___ ____: Decimal ) -> String?
{
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.locale = Locale(identifier: "en_US")
return formatter.string(from: NSDecimalNumber(decimal: ____))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment