I'm trying to use the NSView
call getRectsBeingDrawn(_:count:)
in a Swift app, but can't fathom how to unpack the 'return' values - the method's signature is particularly arcane. I'm getting the expected number of rectangles via the count
variable, but I've no idea how to get access to rectangles in the array. This question addresses the same issue, and proposes a solution, but it's not working for me - I can't get access to NSRect
structs.
func decideWhatToRedraw() {
let r1 = CGRect(x: 0, y: 0, width: 10, height: 20)
let r2 = CGRect(x: 0, y: 100, width: 35, height: 15)
setNeedsDisplayInRect(r1)
setNeedsDisplayInRect(r2)
}
override func drawRect(dirtyRect: NSRect) {
var rects: UnsafeMutablePointer<UnsafePointer<NSRect>> = UnsafeMutablePointer<UnsafePointer<NSRect>>.alloc(1)
var count: Int = 0
getRectsBeingDrawn(rects, count: &count)
// count -> 2
// But how to get the rects?
}