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
| import Foundation | |
| extension Float { | |
| func format(f: String) -> String { | |
| return String(format: "%\(f)f", self) | |
| } | |
| mutating func roundTo(decimals: Int) { | |
| let divisor = pow(10.0, Float(decimals)) | |
| self = round(self * divisor) / divisor | |
| } |
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
| import Foundation | |
| extension NSDate { | |
| func coolDate() -> String { | |
| if self.minutesFromNow() < 1 { | |
| return "Now" | |
| } else if self.minutesFromNow() < 60 { | |
| return numberWithSuffix(self.minutesFromNow(), "m", false) | |
| } else if self.hoursFromNow() < 24 { | |
| return numberWithSuffix(self.hoursFromNow(), "h", false) |
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
| import Foundation | |
| class DictionaryUtils { | |
| class func removeNullsFromDictionary(origin:[String:AnyObject]) -> [String:AnyObject] { | |
| var destination:[String:AnyObject] = [:] | |
| for key in origin.keys { | |
| if origin[key] != nil && !(origin[key] is NSNull){ | |
| if origin[key] is [String:AnyObject] { | |
| destination[key] = self.removeNullsFromDictionary(origin[key] as! [String:AnyObject]) | |
| } else if origin[key] is [AnyObject] { |
NewerOlder