---
title: "NewMusicEventIterator(_:_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/newmusiceventiterator(_:_:)"
---

# NewMusicEventIterator(_:_:)

Creates a new music event iterator.

## Declaration

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

Return Value A result code.

## Discussion

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: Obtain the current position using the MusicEventIteratorGetEventInfo(_:_:_:_:_:) function, and save the position. Dispose of the music event iterator. Create a new iterator. Seek to the desired position using the MusicEventIteratorSeek(_:_:) function.

## See Also

### Iterating Over Music Events

- [DisposeMusicEventIterator(_:)](audiotoolbox/disposemusiceventiterator(_:).md)
- [MusicEventIteratorNextEvent(_:)](audiotoolbox/musiceventiteratornextevent(_:).md)
- [MusicEventIteratorSeek(_:_:)](audiotoolbox/musiceventiteratorseek(_:_:).md)
- [MusicEventIteratorDeleteEvent(_:)](audiotoolbox/musiceventiteratordeleteevent(_:).md)
- [MusicEventIteratorGetEventInfo(_:_:_:_:_:)](audiotoolbox/musiceventiteratorgeteventinfo(_:_:_:_:_:).md)
- [MusicEventIteratorHasCurrentEvent(_:_:)](audiotoolbox/musiceventiteratorhascurrentevent(_:_:).md)
- [MusicEventIteratorHasNextEvent(_:_:)](audiotoolbox/musiceventiteratorhasnextevent(_:_:).md)
- [MusicEventIteratorHasPreviousEvent(_:_:)](audiotoolbox/musiceventiteratorhaspreviousevent(_:_:).md)
- [MusicEventIteratorPreviousEvent(_:)](audiotoolbox/musiceventiteratorpreviousevent(_:).md)
- [MusicEventIteratorSetEventInfo(_:_:_:)](audiotoolbox/musiceventiteratorseteventinfo(_:_:_:).md)
- [MusicEventIteratorSetEventTime(_:_:)](audiotoolbox/musiceventiteratorseteventtime(_:_:).md)
- [MusicEventIterator](audiotoolbox/musiceventiterator.md)
- [MusicEventType](audiotoolbox/musiceventtype.md)
- [ExtendedNoteOnEvent](audiotoolbox/extendednoteonevent.md)
- [ExtendedTempoEvent](audiotoolbox/extendedtempoevent.md)
