---
title: "initWithSize:depth:separate:alpha:"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscachedimagerep/initwithsize:depth:separate:alpha:"
---

# initWithSize:depth:separate:alpha:

Returns a cached image representation initialized with the specified image characteristics.

## Declaration

```occ
- (id) initWithSize:(NSSize) size depth:(NSWindowDepth) depth separate:(BOOL) flag alpha:(BOOL) alpha;
```

## Parameters

- `size`: The size of the image, measured in points.
- `depth`: The bit depth of the image. Specify 0 if you want the image to be the same depth as the deepest screen on the current system.
- `flag`: doc://com.apple.documentation/documentation/Swift/true if the receiver should use a separate offscreen window to store the image; otherwise, doc://com.apple.documentation/documentation/Swift/false if the receiver should use a shared window.
- `alpha`: doc://com.apple.documentation/documentation/Swift/true if the image includes transparency information; otherwise, doc://com.apple.documentation/documentation/Swift/false.

## Return Value

Return Value The initialized NSCachedImageRep object or nil if the object could not be initialized.

## See Also

### Related Documentation

- [setCacheDepthMatchesImageDepth:](appkit/nsimage/setcachedepthmatchesimagedepth:.md)
- [hasAlpha](appkit/nsimagerep/hasalpha.md)
- [setCachedSeparately:](appkit/nsimage/setcachedseparately:.md)
- [bitsPerSample](appkit/nsimagerep/bitspersample.md)

### Initializing Cached Representations of Images

- [initWithWindow:rect:](appkit/nscachedimagerep/initwithwindow:rect:.md)
