In my Swift app I have UIButton
with title
NSLocalizedString("Barrels", comment: "Default oil convert type")
In Russian it will be "Баррели"
, but for the logic of application I need to get the original string "Barrels"
.
For ex.:
let index: Int = find(converter.oilConvertTypes.keys.array, sender.titleForState(UIControlState.Normal)!)!
Here I need to find the index of oilConvertTypes
hash keys by the UIButton
's ( sender
) title. But title is in Russian and in oilConvertTypes
all keys are in English.
Is it possible? Or I need to store original value in some separate var
?
Thanks!
A quick and simple solution would be to create a custom UIButton
subclass with an additional NSString
property for the English title. When it is tapped you can cast sender
to your subclass and check the value of this property.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.