11/*
22 B9Action.swift
33
4- Copyright © 2021 BB9z.
4+ Copyright © 2021-2022 BB9z.
55 https://github.com/b9swift/Action
66
77 The MIT License
1111import Foundation
1212
1313/**
14- A simple base component whose main purpose is to provide a unified interface for target/selector patterns and block calls .
14+ A simple foundational component, primarily intended to provide a uniform interface for target/selector patterns and block invocations .
1515 */
1616public final class Action {
1717 /// The object that receives the selector message when the action is triggered.
@@ -57,7 +57,7 @@ public final class Action {
5757 ///
5858 /// - Parameter obj: An object sent with the selector message to the target, ignored when the closure is called.
5959 public func perform( with obj: Any ? ) {
60- guard isVaild else { return }
60+ guard isValid else { return }
6161 if let selector = selector {
6262 _ = target? . perform ( selector, with: obj)
6363 }
@@ -69,7 +69,7 @@ public final class Action {
6969 /// Whether this action is still or not. Execute the perform method with no action if the action is invalid.
7070 ///
7171 /// If a reference object is set during initialization, it is valid only when the reference is not released.
72- public var isVaild : Bool {
72+ public var isValid : Bool {
7373 if hasReferenceSet, reference == nil { return false }
7474 return true
7575 }
@@ -88,7 +88,7 @@ extension Action {
8888 if #available( iOS 10 . 0 , * ) {
8989 dispatchPrecondition ( condition: . onQueue( . main) )
9090 }
91- guard isVaild else { return }
91+ guard isValid else { return }
9292 if let selector = selector {
9393 UIApplication . shared. sendAction ( selector, to: target, from: sender, for: nil )
9494 }
@@ -111,7 +111,7 @@ extension Action {
111111 if #available( macOS 10 . 12 , * ) {
112112 dispatchPrecondition ( condition: . onQueue( . main) )
113113 }
114- guard isVaild else { return }
114+ guard isValid else { return }
115115 if let selector = selector {
116116 NSApp . sendAction ( selector, to: target, from: sender)
117117 }
@@ -125,14 +125,14 @@ extension Action {
125125
126126extension Action : CustomDebugStringConvertible {
127127 public var debugDescription : String {
128- let properties : [ ( String , Any ? ) ] = [ ( " target " , target) , ( " selector " , selector) , ( " block " , block) , ( " reference " , reference) , ( " isVaild " , isVaild ) ]
129- let propertyDiscription = properties. compactMap { key, value in
128+ let properties : [ ( String , Any ? ) ] = [ ( " target " , target) , ( " selector " , selector) , ( " block " , block) , ( " reference " , reference) , ( " isValid " , isValid ) ]
129+ let propertyDescription = properties. compactMap { key, value in
130130 if let value = value {
131131 return " \( key) = \( value) "
132132 }
133133 return nil
134134 } . joined ( separator: " , " )
135- return " <Action \( Unmanaged . passUnretained ( self ) . toOpaque ( ) ) : \( propertyDiscription ) > "
135+ return " <Action \( Unmanaged . passUnretained ( self ) . toOpaque ( ) ) : \( propertyDescription ) > "
136136 }
137137}
138138
0 commit comments