---
title: "init(iconRef:)"
framework: appkit
role: symbol
role_heading: Initializer
path: "appkit/nsimage/init(iconref:)"
---

# init(iconRef:)

Initializes the image object with a Carbon-style icon resource.

## Declaration

```swift
convenience init(iconRef: IconRef)
```

## Parameters

- `iconRef`: A reference to a Carbon icon resource.

## Return Value

Return Value An initialized NSImage object.

## Discussion

Discussion Creates one or more bitmap image representations, one for each size icon contained in the IconRef data structure. This initialization method automatically retains the data in the iconRef parameter and loads the bitmaps from that data file lazily.

## See Also

### Instance Methods

- [lockFocus()](appkit/nsimage/lockfocus().md)
- [lockFocusFlipped(_:)](appkit/nsimage/lockfocusflipped(_:).md)
- [unlockFocus()](appkit/nsimage/unlockfocus().md)
