ardavar ardavar - 2 years ago 155
iOS Question

Passing multiple tags with UIButton

OK I have a specific situation. I am using a custom class to create some buttons and I can set their tag property with unique numbers like:

button.tag =[NSNumber numberWithInt:[10]];

This is very useful in another part of my program because I can access this unique tag like:

UIButton *clicked= (UIButton *) sender;

ButtonTag = [NSString stringWithFormat:@"%d", clicked.tag];

Now I want to pass one more unique property just like this. I am making this up but this is how I envision it

button.tagCREATED_BY_ME =[NSNumber numberWithInt:[9000]];

The question might be poorly worded but I don't know any better so I called it "tag".(correct wording might be element/property etc) How do I create a similar property to function just like .tag?

Thanks a lot!

Answer Source

In your subclassed/custom button, you can add a string property or even an integer property whichever you feel good.

@interface CustomButton: ....
       @property(strong) NSString *createdBy;


Then you can access those as aButton.createdBy

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download