<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AudioToolbox",
  "identifier" : "/documentation/AudioToolbox/AudioFileWriteBytes(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Audio Toolbox"
    ],
    "preciseIdentifier" : "c:@F@AudioFileWriteBytes"
  },
  "title" : "AudioFileWriteBytes(_:_:_:_:_:)"
}
-->

# AudioFileWriteBytes(_:_:_:_:_:)

Writes bytes of audio data to an audio file.

```
func AudioFileWriteBytes(_ inAudioFile: AudioFileID, _ inUseCache: Bool, _ inStartingByte: Int64, _ ioNumBytes: UnsafeMutablePointer<UInt32>, _ inBuffer: UnsafeRawPointer) -> OSStatus
```

## Parameters

`inAudioFile`

The audio file to which you want to write bytes of data.

`inUseCache`

Set to `true` if you want to cache the data. Otherwise, set to `false`.

`inStartingByte`

The byte offset where the audio data should be written.

`ioNumBytes`

On input, a pointer the number of bytes to write. On output, a pointer to the number of bytes actually written.

`inBuffer`

A pointer to a buffer containing the bytes to be written.

## Return Value

A result code. See Result Codes.

## Discussion

In most cases, you should use [`AudioFileWritePackets(_:_:_:_:_:_:_:)`](/documentation/AudioToolbox/AudioFileWritePackets(_:_:_:_:_:_:_:)) instead of this function.

---

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)