Since what you want is just another UIControlEvent
, you can use (as you were before) the range defined by .applicationReserved
as a free space for you to use. Though, a more correct and easy to use way to do this would be:
(Swift 3.0):
extension UIControlEvents {
static var increased: UIControlEvents { return UIControlEvents(rawValue: 0b0001 << 24) }
static var decreased: UIControlEvents { return UIControlEvents(rawValue: 0b0010 << 24) }
}
In this way you can easily use this definitions everywhere events are supposed to be used, also with the convenience of type inference (e.g. sendActions(for: [.valueChanged, .increased])
).
The declaration also looks cleaner to me as being these bits it's easier to see that they're disjoint by using a shift. Since .applicationReserved
is defined as 0b1111 << 24
, it's more definite which parts of it you're using.
These can be public
if needed, and there's not much difference between having computed var
s like here or just assigning let
constants.