title: How does one create a 'static' in a Swift class extension?
body: <p>In several places here, it has been suggested that using a computed property within an extension of <code>NSDate</code> might a good way to obtain a string version of a date via a <code>NSDateFormatter</code>, like so:</p>
  
  <pre><code>extension NSDate {
      public var UTC : String {
          let formatter = NSDateFormatter()
          formatter.dateFormat = "yyyy-MM-dd HH:mm:ss ZZZ"
          formatter.timeZone = NSTimeZone(abbreviation: "UTC")
          return formatter.stringFromDate(self)
      }
  }
  </code></pre>
  
  <p>However, allocating a <code>NSDateFormatter</code> is expensive and it is suggested that they be created once and cached.  The above code creates the <code>NSDateFormatter</code> every time a date is formatted, and I'm wondering if there is a way to create the <code>NSDateFormatter</code> once inside the extension for reuse?</p>
  
  <p>Obviously, I could create it just once outside the extension, but that seems to defeat the encapsulation that characterizes classes.</p>
  
  <p>I am reminded of: <a href="https://xkcd.com/1179/" rel="noreferrer">https://xkcd.com/1179/</a> !!</p>