Reputation: 1
I wanted to give a string value to UIButton tag for unique identities. but button tag do not understand string valve, it is replace into intger value.
Upvotes: 0
Views: 435
Reputation: 1767
Alternatively, you can subclass UIButton, and declare a NSString variable in the .h file.
@property (nonatomic, strong) NSString *tagString;
You can then either set your buttons' class in Storyboards, or in code, and tag them with your strings by assigning that value. Otherwise, use typedef enum
.
Upvotes: 0
Reputation: 1573
The tag property is an int, and will not take a string.
However, you can create an enum, and then set the tags appropriately.
typedef enum : int {
Tag1 = 1,
Tag2
} MyTag;
...
view.tag = Tag1;
Upvotes: 0
Reputation: 8147
UIView
's tag
property is of NSInteger
type, so you can't place a string there. There are ways you can circumvent this, though (lookup tables, etc).
Upvotes: 1