For an OSX Playground I enter the following code:
import Cocoa
class PlayView : NSView {
override func drawRect(dirtyRect: NSRect) {
let blue = NSColor.blueColor()
blue.setFill()
NSRectFill(self.bounds)
}
}
var view = PlayView(frame: NSRect(x: 0, y: 0, width: 200, height: 200))
I then get this output:
Playground execution failed: <EXPR>:12:18: error: use of undeclared type 'NSView'
class PlayView : NSView {
^~~~~~
<EXPR>:14:39: error: use of undeclared type 'NSRect'
override func drawRect(dirtyRect: NSRect) {
^~~~~~
<EXPR>:25:28: error: use of unresolved identifier 'NSRect'
var view = PlayView(frame: NSRect(x: 0, y: 0, width: 200, height: 200))
^
<EXPR>:16:20: error: use of unresolved identifier 'NSColor'
let blue = NSColor.blueColor()
^
<EXPR>:19:9: error: use of unresolved identifier 'NSRectFill'
NSRectFill(self.bounds)
^
This code was working before a big Playground crash but now it completely dies as if none of the Cocoa classes are being imported but I've imported Cocoa and made sure the playground is set for OSX.
I also can create an iOS equivalent in an iOS configured playground and it works fine but the OSX version is broken.
Any ideas?