Assuming you have all the buttons declared as outlets in your controller and connected them with your view.
Beware: Lots of untested pseudo-code will follow ;-)
@property IBOutlet UIButton *firstPianoKeyButton;
@property IBOutlet UIButton *secondPianoKeyButton;
@property IBOutlet UIButton *thirdPianoKeyButton;
... and so on ...
What you can do now is, to put the buttons one after the other into an array.
Let's say you have a controller with 12 keys, starting with what would usually be the middle C.
NSArray *pianoKeys = [NSArray arrayWithObjects:firstButton, secondButton, thirdButton, ..., nil];
Not nice, and there are more elegant and efficient ways to do this, but that should give the picture.
More on arrays in general: NSArray.
Check out this video here for a "better" way: Create Multiple UIButtons Programmatically. It's for iOS though, but again, it should give the picture :-D
Although check out this one: How do I create a basic UIButton programmatically?
Okay. Now, your controller will receive for example the NoteOn-Event of the D#, that corresponds to the MIDI note number of 63. Assuming this is an integer, we can use that one to access the corresponding element in our pianoKeys-array.
So we need an offset to get the right index, the offset will be 60. Why? Our array starts with index 0, but our note numbers of the 12 key piano start with 60.
On a full 88-key piano, the first MIDI note number starts with 21, so that would be the index in that case.
Now, that we can calculate the array index with the MIDI note number of the pressed key and can therefore display the corresponding button in the view as pressed.
[pianoKeys objectAtIndex:(63-60)];
Hope this is helpful.