Best way to handle enable/disable of UIButtons on iPhone
- by Anonymous
I have an increase button and a decrease button, both of which affect a variable. The variable has a minimum and the decrease button will be disabled once that minimum is reached. Likewise for the maximum value of the variable. In my controller, I have two IBActions for both the increase and decrease actions, and two IBOutlets, in order to disable the buttons accordingly. At the bottom of my KVO statement to handle the value change, I have:
increaseButton.enabled = value != MAX;
decreaseButton.enabled = value != MIN;
While this code is functional, I can't help but feel that feel this is a naive approach to the problem, especially since this requires 4 connections. Is there a better solution to this, one that uses fewer connections?