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

# NewMusicEventIterator(_:_:)

Creates a new music event iterator.

```
func NewMusicEventIterator(_ inTrack: MusicTrack, _ outIterator: UnsafeMutablePointer<MusicEventIterator?>) -> OSStatus
```

## Parameters

`inTrack`

The music track to iterate over.

`outIterator`

On output, the newly created music event iterator.

## Return Value

A result code.

## Discussion

A newly-created music event iterator points at the first event on the music track specified in the `inTrack` parameter.

If you edit a music track after associating it with a music event iterator, you must discard iterator and create a new one. Perform the following steps after editing the track:

1. Obtain the current position using the [`MusicEventIteratorGetEventInfo(_:_:_:_:_:)`](/documentation/AudioToolbox/MusicEventIteratorGetEventInfo(_:_:_:_:_:)) function, and save the position.
2. Dispose of the music event iterator.
3. Create a new iterator.
4. Seek to the desired position using the [`MusicEventIteratorSeek(_:_:)`](/documentation/AudioToolbox/MusicEventIteratorSeek(_:_:)) 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)