     /// The closure to be called when the text field did begin editing.
     var didBeginEditingClosure: TextFieldAction? {
         get {
-            return objc_getAssociatedObject(self, AssociatedKeys.textFieldDidBeginEditingHandle) as? TextFieldAction
-        }
-        set {
-            objc_setAssociatedObject(self, AssociatedKeys.textFieldDidBeginEditingHandle, (newValue as! AnyObject!), .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
-            manageDelegate()
-        }
-    }
-
+            guard let boxedValue = objc_getAssociatedObject(self, AssociatedKeys.textFieldDidBeginEditingHandle) as? Box<TextFieldAction> else { return nil }
+            return boxedValue.value
+        }
+        set {
+            let boxedValue: Box<TextFieldAction>? = newValue != nil ? Box(value: newValue!) : nil
+            objc_setAssociatedObject(self, AssociatedKeys.textFieldDidBeginEditingHandle, boxedValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
+            manageDelegate()
+        }
+    }
+    
     /// The closure to be called when the text field end begin editing.
     var didEndEditingClosure: TextFieldAction? {
         get {
-            return objc_getAssociatedObject(self, AssociatedKeys.textFieldDidEndEditingHandle) as? TextFieldAction
-        }
-        set {
-            objc_setAssociatedObject(self, AssociatedKeys.textFieldDidEndEditingHandle, (newValue as! AnyObject!), .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
+            guard let boxedValue = objc_getAssociatedObject(self, AssociatedKeys.textFieldDidEndEditingHandle) as? Box<TextFieldAction> else { return nil }
+            return boxedValue.value
+        }
+        set {
+            let boxedValue: Box<TextFieldAction>? = newValue != nil ? Box(value: newValue!) : nil
+            objc_setAssociatedObject(self, AssociatedKeys.textFieldDidEndEditingHandle, boxedValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
             manageDelegate()
         }
     }

        `AssociatedKeys`
    
        A private struct which holds the keys for retrieving associated values.
     */
    private struct AssociatedKeys {
        /// The handle for retrieving or storing the text field delegate as an associated value.
        static let textFieldDelegateHandle = "textFieldDelegateHandle"

        /// The handle for retrieving or storing the `shouldBeginEditingClosure` as an associated value.
        static let textFieldShouldBeginEditingHandle = "textFieldShouldBeginEditingHandle"
        /// The handle for retrieving or storing the `shouldEndEditingClosure` as an associated value.

    /// The closure to be called to determine whether the text field should begin editing.
    var shouldBeginEditingClosure: TextFieldResponse? {
        get {
            guard let boxedValue = objc_getAssociatedObject(self, AssociatedKeys.textFieldShouldBeginEditingHandle) as? Box<TextFieldResponse> else { return nil }
            return boxedValue.value
        }
        set {
            let boxedValue: Box<TextFieldResponse>? = newValue != nil ? Box(value: newValue!) : nil
            objc_setAssociatedObject(self, AssociatedKeys.textFieldShouldBeginEditingHandle, boxedValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
            manageDelegate()
        }
    }
    
    /// The closure to be called to determine whether the text field should end editing.
    var shouldEndEditingClosure: TextFieldResponse? {
        get {
            guard let boxedValue = objc_getAssociatedObject(self, AssociatedKeys.textFieldShouldEndEditingHandle) as? Box<TextFieldResponse> else { return nil }
            return boxedValue.value
        }
        set {
            let boxedValue: Box<TextFieldResponse>? = newValue != nil ? Box(value: newValue!) : nil
            objc_setAssociatedObject(self, AssociatedKeys.textFieldShouldEndEditingHandle, boxedValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
            manageDelegate()
        }
    }
