[Solved] IBOutlet Array declaration [closed]


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

2

solved IBOutlet Array declaration [closed]