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;
@interface MyButton:UIButton
@property(nonatomic, assign) int number;
@property(nonatomic, strong) NSString *owner
@end
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;
@interface UIButton(MyCategory)
@property(nonatomic, assign) float number;
@property(nonatomic, strong) NSString *owner;
@end
@implementation UIButton(MYCategory)
NSString *const numberKey = @"kNumberKey";
NSString *const ownerKey = @"kOwnerKey";
- (float)number{
return [objc_getAssociatedObject(self, &numberKey) floatValue];
}
-(void)setNumber:(float)num{
objc_setAssociatedObject(self, &numberKey,[NSNumber numberWithFloat:num], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
-(NSString*)owner{
return objc_getAssociatedObject(self, &ownerKey);
}
-(void)setOwner:(NSString *)own{
objc_setAssociatedObject(self, &ownerKey, own, OBJC_ASSOCIATION_COPY);
}
@end
With this you will be able to add the custom properties to the UIButton class itself.