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 DateFormatter { | |
/* | |
DateFormatters are notoriously slow to create, so it's best to share them. | |
However, they're not thread safe, so this returns one DateFormatter per thread. | |
*/ | |
static var shared : DateFormatter { | |
let key = "com.relium.swift.DateFormatter" | |
if let f1 = Thread.current.threadDictionary[key] as? DateFormatter { | |
return f1 | |
} |
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
Reasons to create UIs in code rather than Storyboards: | |
Merge conflicts | |
Easier to diff revisions and see changes in code | |
More flexibility to move UI elements on iPad vs iPhone, | |
portrait vs landscape | |
Easier theme support |