diff --git a/Sources/CommonAppleKit/CommonAppleKit.swift b/Sources/CommonAppleKit/CommonAppleKit.swift index e343211..394e083 100644 --- a/Sources/CommonAppleKit/CommonAppleKit.swift +++ b/Sources/CommonAppleKit/CommonAppleKit.swift @@ -53,6 +53,26 @@ #endif public typealias CAControl = UIControl + public extension CAControl { + func addTargetForPrimaryActionTriggered( + _ target: AnyObject, + action: Selector + ) { + addTarget(target, action: action, for: .primaryActionTriggered) + } + + func addTargetForValueChanged( + _ target: AnyObject, + action: Selector + ) { + addTarget(target, action: action, for: .valueChanged) + } + + func actions(for target: Any) -> [String] { + actions(forTarget: target, forControlEvent: .primaryActionTriggered) ?? [] + } + } + public extension CALabel { var stringValue: String { get { @@ -91,17 +111,6 @@ setImage(image, for: state) } } - - func addTargetForPrimaryActionTriggered( - _ target: AnyObject, - action: Selector - ) { - addTarget(target, action: action, for: .primaryActionTriggered) - } - - func actions(for target: Any) -> [String] { - actions(forTarget: target, forControlEvent: .primaryActionTriggered) ?? [] - } } public extension CAViewController { @@ -201,6 +210,12 @@ } } + public extension CASwitch { + var isOn: Bool { + state == .on + } + } + public extension CAButton { func setTitle(_ title: String) { self.title = title