I would like to associate a sound effect when pressing down a uibutton. So far i have associate a method to the touch down event
[allButton addTarget:self action:@selector(showAll) forControlEvents:UIControlEventTouchDownInside];
and call the play sound method within the method called:
- (void)showAll
{
[self.buttonSoundEffect play];
...
}
Is there a better way to do this? Can I subclass the UIButton class to handle the sound effect and refer to this new UIButton class for each button specific to my app?
I believe creating a category is the way to go.
I proceed this way:
.h:
.m:
Now each time I create a button that play some sound I just need to use the following method: