I’m looking to add a .owner and .number method to the UIButton class. I need to assign each individual number an (int)number so that I can use numbers to separate the buttons.
e.g so I could write buttonName.number = 1 and buttonName.owner = @"Player1";
How can I go about doing this?
There are few ways to do this thing. The easier one is to subclass the UIButton class and add the properties as you needed which could be achieved as;
And the other way is to use runtime to add properties into the class. For this you would create a category for the class and then add property into the interface and then add properties to it using the runtime as;
With this you will be able to add the custom properties to the UIButton class itself.