---
title: "init(contentsOfFile:byReference:)"
framework: appkit
role: symbol
role_heading: Initializer
path: "appkit/nssound/init(contentsoffile:byreference:)"
---

# init(contentsOfFile:byReference:)

Initializes the receiver with the audio data located at a given filepath.

## Declaration

```swift
init?(contentsOfFile path: String, byReference byRef: Bool)
```

## Parameters

- `path`: Path to the sound file with which the receiver is to be initialized.
- `byRef`: When doc://com.apple.documentation/documentation/Swift/true only the name of the sound is stored with the NSSound instance when archived using doc://com.apple.documentation/documentation/Foundation/NSCoding/encode(with:); otherwise the audio data is archived along with the instance.

## Return Value

Return Value Initialized NSSound instance.

## See Also

### Creating Sounds

- [canInit(with:)](appkit/nssound/caninit(with:).md)
- [init(contentsOf:byReference:)](appkit/nssound/init(contentsof:byreference:).md)
- [init(data:)](appkit/nssound/init(data:).md)
- [init(pasteboard:)](appkit/nssound/init(pasteboard:).md)
