Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7698995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:22:28+00:00 2026-05-31T22:22:28+00:00

I am trying to figure out something – Every time I use AVAudioPlayer I

  • 0

I am trying to figure out something –

Every time I use AVAudioPlayer I need to initialize a new AVAudioPlayer object.

I have 10 Sentence objects on a view and I wish to add a “PlaySentence” method to each Sentence object so when the user taps the Sentence the app will play a sound file.

I need this behavior on many views, so I thought adding the method to the object class so I can simply call –

[Sentence playSound];

Since AVAudioPlayer is any way initialized every time I wish to use it I can not see why this should be more expensive operation.

Am I right / is it a good approch for this need and why?

Thanks

Shani

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:22:29+00:00Added an answer on May 31, 2026 at 10:22 pm

    So if I understand you right, you want your Sentence object have a playSound method which sets up an AVAudioPlayer and plays the sound.

    You can definitely do it like that, but be aware that if you have a lot of Sentence objects then you will end up creating a lot of AVAudioPlayer objects. But you could stop the high water line being too high by releasing it at after the file has finished playing.

    Another way you could do this is to have a method on Sentence to return the URL of the file to play and then just have a single AVAudioPlayer instance in your view controller where you want to play the sounds and set it up each time for the correct file. This would be my personal suggested way of doing it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to regex and trying to figure something out for use in scala.
I'm trying to figure out if I'm totally mis-understanding something here. I have a
I am trying to figure out if I have something wrong with my architecture,
I'm trying to figure out how have something like Enter an expression: take in
I learned something new while trying to figure out why my readwrite property declared
Folks, I'm new to Scala and am trying to figure something out. I've been
I'm fairly new to CodeIgniter, and am trying to figure out something I feel
This is something that I have been trying to figure out for a while
I am trying to figure out something with EF4 Code Only. If i use
Trying to figure out the best way to do this: Should I do something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.