Challenge: NSBezierPath-base Hit Testing

Managed to get this one working.

  1. Added a variable for the die path:

var diePath: NSBezierPath?

  1. Altered the draw code to update the variable in func drawDieWithSize()

    self.diePath = NSBezierPath(roundedRect: dieFrame, xRadius: cornerRadius, yRadius: cornerRadius)

  2. Changed the hit test to use the path

    override func mouseDown(theEvent: NSEvent) {
    let pointInView = convertPoint(theEvent.locationInWindow, fromView: nil)
    pressed = (self.diePath?.containsPoint(pointInView))!