Question: In a subclass of `UIView` I declared a property. This property is an instance of `UIPanGestureRecognizer` and is not optional or implicitly unwrapped. Here is the code:

```
class DraggableView: UIView {

    let panGestureRecognizer: UIPanGestureRecognizer

    override init() {

        panGestureRecognizer = UIPanGestureRecognizer(target: self, action: "dragged:")

        super.init()

        backgroundColor = UIColor.greenColor()

    }

    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}

```

Here on the the initialization line of `panGestureRecognizer` Xcode gives an error: "self used before super.init call". If I move `super.init()` line above the `panGestureRecognizer` initialization line, Xcode gives another error: "Property `self.panGestureRecognizer` not initialized at `super.init` call". The last attempt made was to initialize `panGestureRecognizer` in its declaration outside of the `init` method. Like this:

`let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: "dragged:")`

Here Xcode gives yet another error: "Type `DraggableView -> () -> DraggableView!` does not conform to protocol `AnyObject`"

Is there a way to make this work without using optionals or implicitly unwrapped optionals?

Answer: 
The problem is that `self` doesn't exist before `super.init()` has happened. 

You can create it in two steps - initialise at declaration time:

```
let panGestureRecognizer = UIPanGestureRecognizer()

```

Then after `super.init()`, add the target:

```
panGestureRecognizer.addTarget(self, action: "dragged:")

```

Alternatively you could make it a `lazy var` but I don't like making things variable unless they're supposed to vary.
You can declare the property as `lazy`, but at the cost of turning it into a mutable:

```
lazy var panGestureRecognizer: UIPanGestureRecognizer = UIPanGestureRecognizer(target: self, action: "dragged:")

```

However I recommend making it an implicitly unwrapped optional - that's the pattern commonly used in view controllers with outlets.