---
title: "MusicEventIteratorPreviousEvent(_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/musiceventiteratorpreviousevent(_:)"
---

# MusicEventIteratorPreviousEvent(_:)

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

## Declaration

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

## Parameters

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

## Return Value

Return Value A result code.

## Discussion

Discussion Use this function to decrement a music event iterator, moving it backward through a music track’s events. If an iterator is at the first event of a track when you call this function, the iterator position remains unchanged and this function returns an error. The following code snippet illustrates how to use a music event iterator to proceed backward along a music track, from the end: // Points iterator just beyond the final event on its music track MusicEventIteratorSeek (myIterator, kMusicTimeStamp_EndOfTrack);   bool hasPreviousEvent; MusicEventIteratorHasPreviousEvent (myIterator, &hasPreviousEvent); while (hasPreviousEvent) {     MusicEventIteratorPreviousEvent (myIterator);         // do work here     MusicEventIteratorHasPreviousEvent (myIterator, &hasPreviousEvent); }

## See Also

### Iterating Over Music Events

- [NewMusicEventIterator(_:_:)](audiotoolbox/newmusiceventiterator(_:_:).md)
- [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)
- [MusicEventIteratorSetEventInfo(_:_:_:)](audiotoolbox/musiceventiteratorseteventinfo(_:_:_:).md)
- [MusicEventIteratorSetEventTime(_:_:)](audiotoolbox/musiceventiteratorseteventtime(_:_:).md)
- [MusicEventIterator](audiotoolbox/musiceventiterator.md)
- [MusicEventType](audiotoolbox/musiceventtype.md)
- [ExtendedNoteOnEvent](audiotoolbox/extendednoteonevent.md)
- [ExtendedTempoEvent](audiotoolbox/extendedtempoevent.md)
