Из сессии 245 WWDC 2012 (переведено на Swift):
let viewToCapture = self.window!.contentView!
let rep = viewToCapture.bitmapImageRepForCachingDisplayInRect(viewToCapture.bounds)!
viewToCapture.cacheDisplayInRect(viewToCapture.bounds, toBitmapImageRep: rep)
let img = NSImage(size: viewToCapture.bounds.size)
img.addRepresentation(rep)