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 7438523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:34:04+00:00 2026-05-29T10:34:04+00:00

Basically I want to create 48 button outlets. I have created the buttons in

  • 0

Basically I want to create 48 button outlets. I have created the buttons in the interface builder and I want to be able to connect them to the outlets.

I need to be able play a sound when I press one of the buttons. But the sound file that is played should be customizable.

I want smth like:

//first create the outlets
for(int i=1;i<49;i++){
    IBOutlet UIButton [Nstring of type (@"but%d"), i];
    [add butt"i" to array];
}

//then connect the outlets to the buttons

//listen for buttons pressed
while(1){ //or the listener equivalent don't know exactly how i works
    for(int i=1;i<49;i++){
        if(array[i].pressed==TRUE){
              //if button is pressed play the according file
              playsound(sounds[i]);
        }
    }
}

I need to be able to easily change the file that is played
Thank you

  • 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-29T10:34:05+00:00Added an answer on May 29, 2026 at 10:34 am

    You probably need more practice with Xcode/Objective-C basics and idioms.
    Your approach is not valid (for instance, on iOS, we don’t loop (while(1)) to listen for events).

    Find some books, and you will be able to make your own soundboard soon.

    If you want to persist, here is some hints :
    Assuming you place manually your buttons on the XIB view.
    Assign differents tag (for instance from 1000 to 1048) to every buttons and bind them with an action :

    // In your .h file
    - (IBAction)didTouchButton:(UIButton * )sender;
    

    Then you need to implement the action :

    // In you .m file
    - (IBAction)didTouchButton:(UIButton * )sender {
    NSString * fileName = [NSString stringWithFormat:@"%d", sender.tag];
    NSURL *url = [[NSBundle mainBundle] URLForResource:fileName withExtension: @"mp3"];
    if (!url){NSLog(@"file not found"); return;}
    NSError *error;
    self.audio = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error] ;
    ;
    }
    

    Create a property for self.audio (@property in your .h and @synthesize in your .m).
    Rename your 48 sounds with name from 1000.mp3 to 1048.mp3, and add them in your project.
    Add the framework AVFoundation.framework (target->build phase->Link binaries with librairies-> +).

    When you click on button with tag N, it will play the sound with the name N.mp3.

    Good luck

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

Sidebar

Related Questions

Basically i want to be able to dynamically create a temp table based off
I want to create a button that is basically Windows' close button. How could
Basically, I have a button and on click it displays a menu. I want
Basically, I want to create a button underneath a grouped table view, like contacts.app
How can I create in a Swing interface a toggle image button? I have
I have a button that i basically want to either show or hide it
Basically, I want to create a table like this: I created a grid, and
Basically I want to create one large object of many object in JavaScript. Something
I want to create own filetype to save objects in my app. Basically, I
How to create imaged scrollbars, for example: http://www.openstudio.fr/jquery/index.htm Basically, I want to create my

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.