April 2015
Intermediate to advanced
556 pages
17h 47m
English
As mentioned previously, the NSRect that is passed as an argument to the view is the region that is “dirty” and needs redrawing. It may be less than the entire view. If you are doing very time-consuming drawing, redrawing only the dirty rectangle may speed up your application considerably.
Note that setting needsDisplay to true
will trigger the entire visible region of the view to be redrawn.
If you wanted to be more precise about which part of the view needs redrawing,
you would use setNeedsDisplayInRect(_:) instead:
let dirtyRect = NSRect(x: 0, y: 0, width: 50, height: 50) myView.setNeedsDisplayInRect(dirtyRect)
Read now
Unlock full access