1

I made this extension to NSView to make it easier to work with views.

import Cocoa

public extension NSView {
    var invertedFrame: NSRect {
    get {
        return NSRect(x: frame.origin.x,
                      y: superview.bounds.height - frame.origin.y,
                  width: bounds.size.width,
                 height: bounds.size.height)
    }
    set {

        self.frame = NSRect(x: newValue.origin.x,
                            y: superview.bounds.height - newValue.origin.y - newValue.height,
                        width: newValue.width,
                       height: newValue.height)
    }
    }
}

But whenever I try to use it I get the compile time error ...

Command /Applications/Xcode6-Beta4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254

However if I cut and paste the computed variable into a class implementation it works fine.

I am not sure why this is. Is there something wrong with my code? Can anyone make this work?

o.uinn
  • 838
  • 1
  • 8
  • 13

2 Answers2

0

Your property setter doesn't declare newValue as a method parameter, but instead of telling you that, the compiler is clearly crashing. Remember that a bare set is found only in a protocol property declaration.

NRitH
  • 13,441
  • 4
  • 41
  • 44
0

I'm not sure which update fixed this, but in Xcode 6 beta 5 it works fine. So it was just a compiler bug.

o.uinn
  • 838
  • 1
  • 8
  • 13