あなたがやりたいことは、すでに明示的に利用可能です。10.4 AppKit リリース ノートの「NSView Drawing Redirection API」セクションを参照してください。
キャッシュ用の NSBitmapImageRep を作成し、クリアします。
NSGraphicsContext *bitmapGraphicsContext = [NSGraphicsContext graphicsContextWithBitmapImageRep:cacheBitmapImageRep];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:bitmapGraphicsContext];
[[NSColor clearColor] set];
NSRectFill(NSMakeRect(0, 0, [cacheBitmapImageRep size].width, [cacheBitmapImageRep size].height));
[NSGraphicsContext restoreGraphicsState];
それにキャッシュします。
-[NSView cacheDisplayInRect:toBitmapImageRep:]
ビューの再帰と透明性を正しく処理する指定されたコンテキストに、より一般的に描画したい場合は、
-[NSView displayRectIgnoringOpacity:inContext:]