Disposing of System Sounds

Don’t forget to dispose of system sounds. Your dealloc method is a natural place to wrap up matters at an object’s end of life. Always consider the life cycle of your sounds and find an approach to manage the disposal of the sound.

For many applications, a few sounds can persist for the duration of an object’s (or even an application’s) lifetime without placing a burden on memory. For others, you’ll want to clean up after yourself as soon as the sound is played. Make sure to design sound disposal into your applications and ensure that you dispose of resources when you’re done with them.

In recent versions of Xcode, the iOS simulator offers full sound playback.

Recipe 3-7 Playing Sounds, Alerts, and Vibrations Using ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.