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

# AudioFileSetUserData(_:_:_:_:_:)

Sets a user data item in an audio file.

```
func AudioFileSetUserData(_ inAudioFile: AudioFileID, _ inUserDataID: UInt32, _ inIndex: UInt32, _ inUserDataSize: UInt32, _ inUserData: UnsafeRawPointer) -> OSStatus
```

## Parameters

`inAudioFile`

The audio file that you want to set a user data item in.

`inUserDataID`

The four-character code for the user data item.

`inIndex`

An index specifying the user data item you want to set. You use this parameter if the file contains more than one user data item with the four-character code specified in the `inUserDataID` parameter.

`inUserDataSize`

On input, the size of the data to copy. On output, the size of the bytes copied from the buffer.

`inUserData`

A pointer to a buffer from which to copy the user data.

## Return Value

A result code if there’s an error (see Result Codes) or `noErr` if the operation succeeds.

## Discussion

---

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)