---
title: "init(forWriting:settings:commonFormat:interleaved:)"
framework: avfaudio
role: symbol
role_heading: Initializer
path: "avfaudio/avaudiofile/init(forwriting:settings:commonformat:interleaved:)"
---

# init(forWriting:settings:commonFormat:interleaved:)

Opens a file for writing using a specified processing format and settings.

## Declaration

```swift
init(forWriting fileURL: URL, settings: [String : Any], commonFormat format: AVAudioCommonFormat, interleaved: Bool) throws
```

## Parameters

- `fileURL`: The path at which to create the file.
- `settings`: The format of the file to create.
- `format`: The processing format to use when writing to the file.
- `interleaved`: The Boolean value that indicates whether to use an interleaved processing format.

## Return Value

Return Value A new AVAudioFile instance for writing.

## Discussion

Discussion This method infers the file type to create from the file extension of fileURL, and overwrites a file at the specified URL if a file exists. For more information about the settings parameter, see the settings property in the AVAudioRecorder class.

## See Also

### Related Documentation

- [url](avfaudio/avaudiofile/url.md)
- [processingFormat](avfaudio/avaudiofile/processingformat.md)

### Creating an Audio File

- [init(forReading:)](avfaudio/avaudiofile/init(forreading:).md)
- [init(forReading:commonFormat:interleaved:)](avfaudio/avaudiofile/init(forreading:commonformat:interleaved:).md)
- [init(forWriting:settings:)](avfaudio/avaudiofile/init(forwriting:settings:).md)
