---
title: "initWithWindow:rect:"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscachedimagerep/initwithwindow:rect:"
---

# initWithWindow:rect:

Returns a cached image representation initialized for drawing in the specified window.

## Declaration

```occ
- (id) initWithWindow:(NSWindow *) win rect:(NSRect) rect;
```

## Parameters

- `win`: The window (typically offscreen) in which the image is to be rendered. The window is retained by the receiver.
- `rect`: The position and size of the image in the specified window. This rectangle should be specified in the base coordinate system of the window.

## Discussion

Discussion You must draw the image yourself in the designated part of the window. There are no NSCachedImageRep methods for this purpose.

## See Also

### Related Documentation

- [size](appkit/nsimagerep/size.md)

### Initializing Cached Representations of Images

- [initWithSize:depth:separate:alpha:](appkit/nscachedimagerep/initwithsize:depth:separate:alpha:.md)
