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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:55:40+00:00 2026-06-17T11:55:40+00:00

I have a app with images and once the user presses the image a

  • 0

I have a app with images and once the user presses the image a sound clip will be played. Once i reach the last image (25), which does not have a sound clip, if i press that the app gets closed automatically how can i prevent this.

For example i need to play C01.mp3 once the user Click 01.Png ( Note all my images are also kept in a image array ) Basically I have 25.png this is just a advertisement to my site so it would not have a sound clip but once i click that image the applicaiton gets close automatically. Need help to sort this out.

//

#import "SoundsGenerator.h"


@implementation SoundsGenerator

- (id) init
{
    CFBundleRef mainBundle;
    mainBundle = CFBundleGetMainBundle ();

    soundObjects=[[NSMutableArray alloc] init];

    NSMutableArray *soundNames = [[NSMutableArray alloc] initWithObjects:@"c1",
                                @"c2", 
                                @"c3", 
                                @"c4", 
                                @"c5", 
                                @"c6", 
                                @"c7", 
                                @"c8", 
                                @"c9", 
                                @"c10", 
                                @"c11", 
                                @"c12", 
                                @"c13", 
                                @"c14", 
                                @"c15", 
                                @"c16", 
                                @"c17", 
                                @"c18", 
                                @"c19", 
                                @"c20", 
                                @"c21", 
                                @"c22", 
                                @"c23", 
                                @"c24",nil];    

    for(NSString *soundName in soundNames)
    {
        CFBundleRef mainBundle = CFBundleGetMainBundle();
        CFURLRef soundFileURLRef;
        soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (__bridge CFStringRef)soundName, CFSTR ("mp3"), NULL);

        SystemSoundID soundFileObject;
        // Create a system sound object representing the sound file
        AudioServicesCreateSystemSoundID (soundFileURLRef, &soundFileObject);

        SoundObject *objSound=[[SoundObject alloc] init];
        objSound.soundFileObject=soundFileObject;
        objSound.soundFileURLRef=soundFileURLRef;
        [soundObjects addObject:objSound];
    }

    return self;
}

// Respond to a tap on the System Sound button
- (void) playSound:(int)index 
{
    SoundObject *soundObject=[soundObjects objectAtIndex:index];
    AudioServicesPlaySystemSound ((SystemSoundID)soundObject.soundFileObject);
}


@end
  • 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-06-17T11:55:41+00:00Added an answer on June 17, 2026 at 11:55 am

    replace

    for(NSString *soundName in soundNames)
    {
    

    with

    for(int i = 0 ; i < soundNames.count-1 ; i++)
    {
       NSString *soundName = [soundNames objectAtIndex:i];
       //rest of the code same
    

    This will run the loop till 23 indexes of your 24 indexes array..

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

Sidebar

Related Questions

In my Android app I'd like the user to tap an image once, have
I have one app, a UIImage* . I'm painting the image twice: Once in
I have an app which contain some images in res/drawable/ and shows them in
I have an app that will show some images using UIImageView, now I want
I have an app which is quite huge. It has tons of images and
I have a table where a user clicks on image to block/unblock user. which
I am writing an app which should have the following use case: User clicks
I have a set of about 100 urls which are images. Like http://www.site1.com/Image/img1.jpg and
I have a simple iPhone app that allows the user to upload images to
I have created an app which has a library of images. I have imported

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.