views:

62

answers:

1

hello all assume u r write a code for a piano instrument. Is a good way to make for every button IBAction or all buttons in one function return the sound clicked by the user

thanks all

+1  A: 

It would be much easier to maintain by going with the latter: having all of the buttons point to one IBAction, and the IBAction plays a given note based on which button was pressed rather than having a one-for-one relationship between buttons and IBActions.

Philip Regan
first thanks for the answer but if an user pressed 2 button simultaneously the sounds will out successively this is because i used the pointer in if statement if(button1){ [sound1 play]; }....else{}...is there any way to make sounds out simultaneously
Bobj-C
You really need to specify these requirements in the questions that you ask. At the same time, you also need to just spend time with Apple's documentation. You clearly know what you want to do; you just want the code snippets to do it, but that's not really what SO is about, as far as I'm concerned.
Philip Regan