I am making an iPhone app which uses UIButtons with Placeholder text on them to add and subtract pre-defined constant values; that is, if there are 3 buttons, titled A, B, and C, each of which have numerical values associated with them, I need the most simple way possible to take the values of the buttons, (which isnt explicitly shown on each button) and add them together. So if A=x and B=y, and a user pressed button A and B, and then hit an enter or calculate button, the value of A+B (x+y) would be calculated and displayed. My current plan is to use an NSArray, and append the values of A and B onto it, but as always, a second opinion is welcome. Hopefully this explanation was straightforward enough and easy to understand. I need this to be able to add a (theoretically) infinite number of variables. I.e: A and B multiple times, but also C, D, E…etc. This is the main reason why I was considering NSArray.
I am making an iPhone app which uses UIButton s with Placeholder text on
Share
You can make a subClass of UIButton that holds some data associated with it. Either you can set tags of your buttons and using tags as indexes take data from your NSArray.