<p>For part of my application I have a need to create an image of a certain view and all of its subviews.</p>

<p>To do this I'm creating a context that wraps a bitmap with the same-size as the view, but I'm unsure how to draw the view hierarchy into it. I can draw a single view just be setting the context and explicitly calling drawRect, but this does not deal with all of the subviews.</p>

<p>I can't see anything in the NSView interface that could help with this so I suspect the solution may lie at a higher level.</p>

You can use
```
-[NSView dataWithPDFInsideRect:]
```
to render the entire hierarchy of the view you send it to into a PDF, returned as an
```
NSData
```
object.  You can then do whatever you wish with that, including render it into a bitmap.
Are you sure you want a bitmap representation though?  After all, that PDF could be (at least in theory) resolution-independent.