---
title: "prepare(completion:)"
framework: phase
role: symbol
role_heading: Instance Method
path: "phase/phasesoundevent/prepare(completion:)"
---

# prepare(completion:)

Enables a sound event to play and runs the argument code when the sound event plays back.

## Declaration

```swift
func prepare(completion handler: (@Sendable (PHASESoundEvent.PrepareHandlerReason) -> Void)? = nil)
```

```swift
func prepare() async -> PHASESoundEvent.PrepareHandlerReason
```

## Parameters

- `handler`: Code the framework runs when sound event preparation completes. If you pass nil, no code runs when preparation completes.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func prepare() async -> PHASESoundEvent.PrepareHandlerReason For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. This function instructs the engine to prepare a sound event and returns immediately. When the preparation completes or fails, the framework runs completionHandler. If you call start(completion:) before completionHandler runs, the framework queues the sound event to occur when preparation completes.

## See Also

### Preparing Playback

- [PHASESoundEvent.PrepareHandlerReason](phase/phasesoundevent/preparehandlerreason.md)
- [prepareState](phase/phasesoundevent/preparestate-swift.property.md)
- [PHASESoundEvent.PrepareState](phase/phasesoundevent/preparestate-swift.enum.md)
