👷♂️
This file contains 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 { | |
func firstToUpper() -> String { | |
return self.isEmpty ? "" : String(self.characters.first!).uppercaseString + String(self.characters.dropFirst()).lowercaseString | |
} | |
} |
This file contains 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
func postMainThreadNotificationName(name: String, object: AnyObject?, userInfo: [NSObject : AnyObject]?) { | |
dispatch_async(dispatch_get_main_queue(), { | |
NSNotificationCenter.defaultCenter().postNotificationName(name, object: object, userInfo: userInfo) | |
}) | |
} |
This file contains 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
// SwingUtilities.invokeLater ;-) | |
func invokeLater(delay: CGFloat, code: () -> Void) { | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(delay * CGFloat(NSEC_PER_SEC))), dispatch_get_main_queue(), code) | |
} | |
// Usage: | |
invokeLater(0.1) { | |
doSomething() | |
} |