Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1.  
  2. extension NSCalendar {
  3.  
  4. private struct Keys {
  5. static let calendarKey = "SharedGregorianCalendar"
  6. }
  7.  
  8. class var sharedGregorianCalendar: NSCalendar {
  9. let threadDictionary = NSThread.currentThread().threadDictionary
  10. if let calendar = threadDictionary[Keys.calendarKey] as? NSCalendar {
  11. return calendar
  12. } else {
  13. let calendar = NSCalendar(calendarIdentifier: NSGregorianCalendar)!
  14. threadDictionary[Keys.calendarKey] = calendar
  15. return calendar
  16. }
  17. }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement