I have custom UI element designed with a help of IBInspectables
, so that I can use and modify it in the Interface Builder. There are 2 inspectables which effectively change the same property of the element but in a slightly different manner.
At the screenshot there is title
that sets the title of the element, and locTitleKey
that gets NSLocalizedString
by the key and sets it as the title.
As I can see from passing different values to these inspectables:
- If
locTitleKey
is specified, andtitle
is left empty, the localised string is used - If both are specified,
title
is used and localized one is ignored
The question - is that behaviour predictable?
In other words, can I safely assume that the order of evaluation of my IBInspectables
always be the same? (title
and then locTitleKey
)
To provide more context here are the snippets of code used.
title
is defined in the scope of the class itself:
@IBDesignable
class StandardInputField: UIView, NibLoadable {
//...
@IBInspectable
public var title: String? {
didSet {
titleLabel.text = title
}
}
//...
}
And locTitleKey
is defined as extension:
extension StandardInputField {
@IBInspectable var locTitleKey: String? {
get {
return nil
}
set(key) {
title = key?.localized
}
}
}