Created
September 23, 2014 14:31
-
-
Save vikdenic/08c1c7f0b7d1ecc96c86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension String | |
| { | |
| ///:returns: The floating-point value of the string as a double. | |
| func toDouble() -> Double | |
| { | |
| let convertedString = self as NSString | |
| return convertedString.doubleValue | |
| } | |
| ///:returns: The NSInteger value of the string. | |
| func toInteger()-> Int | |
| { | |
| let convertedString = self as NSString | |
| return convertedString.integerValue | |
| } | |
| } | |
| extension Double | |
| { | |
| ///:returns: The the US Dollars representation of the double rounded to the nearest hundreth, as a String (i.e. $7.45) | |
| func toCurrency() ->String | |
| { | |
| let convertedString = NSString(format: "$%.2f", self) | |
| return convertedString | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment