Is there any way of sharing getter and setter through properties in Swift?
<p>I'm building a helper to enable typed access to <code>NSUserDefaults</code> properties. Something like this:</p>

<pre><code>struct UserDefaults {

  private static var standardUserDefaults: NSUserDefaults = {
    return NSUserDefaults.standardUserDefaults()
  }()

  private static let propKey = "PROP"
  static var prop: Bool {
    get {
      return standardUserDefaults.boolForKey(propKey)
    }
    set {
      standardUserDefaults.setBool(newValue, forKey: propKey)
      standardUserDefaults.synchronize()
    }
  }

}
</code></pre>

<p>This way I can have a nice syntax for reading and writing to <code>NSUserDefaults</code>:</p>

<pre><code>UserDefaults.prop // read
UserDefaults.prop = false // write
</code></pre>

<p>The problem is that there's a lot of boilerplate code for this, I need 10 lines for each aditional property.</p>

<p>Is there any way of reducing the amount of lines needed for each new property? Reusing getter and setter? Any kind of run time generator?</p>