I need to know how many times a button in my program has been pressed. I tried making a category of UIButton and adding properties to it so that each time a button is pressed I would say sender.someproperty++; but the compiler complains when I add properties to a category.
Any way I can track this? I wish every object in Xcode had a random unassigned integer property that you could randomly assign it different values to keep track of each object
the first time I press the button, I want something to happen, the second time, I want something else to happen, the third time, I want something else to happen, and then the fourth time I want it to default so its like I’m pressing it the first time.
Subclassing UIButton is definitely dangerous, because UIButton not a single class but a class cluster. I highly recommend not doing this. According to Apple:
Instead of adding a property to the category, you can use associative references and add getter and setter methods to the category to simulate a property on the button.