---
title: "AudioFileSetUserData(_:_:_:_:_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/audiofilesetuserdata(_:_:_:_:_:)"
---

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

Sets a user data item in an audio file.

## Declaration

```swift
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

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

## See Also

### Working with User Data

- [AudioFileCountUserData(_:_:_:)](audiotoolbox/audiofilecountuserdata(_:_:_:).md)
- [AudioFileGetUserDataSize(_:_:_:_:)](audiotoolbox/audiofilegetuserdatasize(_:_:_:_:).md)
- [AudioFileGetUserDataSize64(_:_:_:_:)](audiotoolbox/audiofilegetuserdatasize64(_:_:_:_:).md)
- [AudioFileGetUserData(_:_:_:_:_:)](audiotoolbox/audiofilegetuserdata(_:_:_:_:_:).md)
- [AudioFileGetUserDataAtOffset(_:_:_:_:_:_:)](audiotoolbox/audiofilegetuserdataatoffset(_:_:_:_:_:_:).md)
- [AudioFileRemoveUserData(_:_:_:)](audiotoolbox/audiofileremoveuserdata(_:_:_:).md)
