---
title: "MusicEventIteratorNextEvent(_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/musiceventiteratornextevent(_:)"
---

# MusicEventIteratorNextEvent(_:)

Positions a music event iterator at the next event on a music track.

## Declaration

```swift
func MusicEventIteratorNextEvent(_ inIterator: MusicEventIterator) -> OSStatus
```

## Parameters

- `inIterator`: The music event iterator to reposition.

## Return Value

Return Value A result code.

## Discussion

Discussion Use this function to increment the position of a music event iterator forward through a music track’s events. If an iterator is at the final event of a track when you call this function, the iterator then moves beyond the final event. You can detect if the iterator is beyond the final event by calling the MusicEventIteratorHasCurrentEvent(_:_:) function. The following code snippet illustrates how to use a music event iterator to proceed forward along a music track, from the start: // Create a new iterator, which automatically points at the first event // on the iterator's music track.   bool hasCurrentEvent; MusicEventIteratorHasCurrentEvent (myIterator, &hasCurrentEvent); while (hasCurrentEvent) {         // do work here     MusicEventIteratorNextEvent (myIterator);     MusicEventIteratorHasCurrentEvent (myIterator, &hasCurrentEvent); }

## See Also

### Iterating Over Music Events

- [NewMusicEventIterator(_:_:)](audiotoolbox/newmusiceventiterator(_:_:).md)
- [DisposeMusicEventIterator(_:)](audiotoolbox/disposemusiceventiterator(_:).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)
