     /// The closure to be called to determine whether the chracters in the text field should change.
     var shouldChangeCharactersClosure: TextFieldChangeCharacters? {
         get {
-            return objc_getAssociatedObject(self, AssociatedKeys.textFieldShouldChangeCharactersHandle) as? TextFieldChangeCharacters
-        }
-        set {
-            objc_setAssociatedObject(self, AssociatedKeys.textFieldShouldChangeCharactersHandle, (newValue as! AnyObject!), .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
-            manageDelegate()
-        }
-    }
-
+            guard let boxedValue = objc_getAssociatedObject(self, AssociatedKeys.textFieldShouldChangeCharactersHandle) as? Box<TextFieldChangeCharacters> else { return nil }
+            return boxedValue.value
+        }
+        set {
+            let boxedValue: Box<TextFieldChangeCharacters>? = newValue != nil ? Box(value: newValue!) : nil
+            objc_setAssociatedObject(self, AssociatedKeys.textFieldShouldChangeCharactersHandle, boxedValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
+            manageDelegate()
+        }
+    }
+    
     /// The closure to be called to determine whether the text field should clear.
     var shouldClearClosure: TextFieldResponse? {
         get {
-            return objc_getAssociatedObject(self, AssociatedKeys.textFieldShouldClearHandle) as? TextFieldResponse
-        }
-        set {
-            objc_setAssociatedObject(self, AssociatedKeys.textFieldShouldClearHandle, (newValue as! AnyObject!), .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
+            guard let boxedValue = objc_getAssociatedObject(self, AssociatedKeys.textFieldShouldClearHandle) as? Box<TextFieldResponse> else { return nil }
+            return boxedValue.value
+        }
+        set {
+            let boxedValue: Box<TextFieldResponse>? = newValue != nil ? Box(value: newValue!) : nil
+            objc_setAssociatedObject(self, AssociatedKeys.textFieldShouldClearHandle, boxedValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
             manageDelegate()
         }
     }
     /// The closure to be called to determine whether the text field should return.
     var shouldReturnClosure: TextFieldResponse? {
         get {
-            return objc_getAssociatedObject(self, AssociatedKeys.textFieldShouldReturnHandle) as? TextFieldResponse
-        }
-        set {
-            objc_setAssociatedObject(self, AssociatedKeys.textFieldShouldReturnHandle, (newValue as! AnyObject!), .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
+            guard let boxedValue = objc_getAssociatedObject(self, AssociatedKeys.textFieldShouldReturnHandle) as? Box<TextFieldResponse> else { return nil }
+            return boxedValue.value
+        }
+        set {
+            let boxedValue: Box<TextFieldResponse>? = newValue != nil ? Box(value: newValue!) : nil
+            objc_setAssociatedObject(self, AssociatedKeys.textFieldShouldReturnHandle, boxedValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
             manageDelegate()
         }
     }

    /// 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()
        }
    }

    /// 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)
            manageDelegate()
        }
    }

    
    /**
        Manages the fact that we need to be the delegate for this UITextField, but there may be an object that also wants to be the delegate.
    */
    private func manageDelegate() {
        //  if we are not our own delegate we need to set ourselves as such but keep the old delegate for messaging where appropriate
        if let textFieldDelegate = delegate where !(textFieldDelegate is UITextField) {
            self.textFieldDelegate = textFieldDelegate
        }
        
        delegate = self
    }
    
    /// The actual delegate for the text field (besides us).
