I have the following code in swift which doesn't compile:
class CustomView: NSView {
override func drawRect(dirtyRect: NSRect) {
var contextPointer: COpaquePointer = NSGraphicsContext.currentContext()!.graphicsPort()
var context: CGContext? = contextPointer as? CGContext
CGContextSetRGBFillColor(context, 1, 0, 0, 1)
CGContextFillRect(context, CGRectMake(0, 0, 100, 100))
CGContextFlush(context)
}
}
How do I convert COpaquePointer to CGContext?