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
replace
with
This will run the loop till 23 indexes of your 24 indexes array..