Reputation: 4100
I was trying to subclass some UIButtons in oder to obtain a property similar to the button.tag property. In this property I would like to set an MCPeerID. The property must look something like:
button.thePeerID = an MCPeerID
if (button.thePeerID == a peer id)...
Unfortunately the tag property will only hold numbers. I know I have to add a new file of UIButton type and call it like this:
SubclassButton *myButton=[SubclassButton buttonWithType:UIButtonTypeRoundedRect];
But how do I get the desired property?
Upvotes: 0
Views: 629
Reputation: 1142
You'll set that property in your header file (subclassButton.h)
@interface SubclassButton : UIButton
@property (nonatomic, strong) NSString *thePeerId;
@end
…then you can access it as you suggested above:
myButton.thePeerId = @"abcd";
(of course, the type depends on what a McPeerID actually is. adjust accordingly)
Upvotes: 3