<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: 10.0.0 - 10.6.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCachedImageRep/initWithWindow:rect:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCachedImageRep(im)initWithWindow:rect:"
  },
  "title" : "initWithWindow:rect:"
}
-->

# initWithWindow:rect:

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

```
- (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

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

## See Also

[`var size: NSSize`](/documentation/AppKit/NSImageRep/size)

The size of the image representation, measured in points in the user coordinate space.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)