             }
         }
     }
-
-    
-    var partialFormatter: PartialFormatter?
-    
-    let nonNumericSet: CharacterSet = {
-        var mutableSet = (CharacterSet.decimalDigits.inverted as NSCharacterSet).mutableCopy() as! NSMutableCharacterSet
-        mutableSet.removeCharacters(in: PhoneNumberConstants.plusChars)
-        return mutableSet as CharacterSet
+    
+    
+    let partialFormatter: PartialFormatter
+    
+    let nonNumericSet: NSCharacterSet = {
+        var mutableSet = NSMutableCharacterSet.decimalDigit().inverted
+        mutableSet.remove(charactersIn: PhoneNumberConstants.plusChars)
+        return mutableSet as NSCharacterSet
     }()
     
     weak private var _delegate: UITextFieldDelegate?

    /// Override region to set a custom region. Automatically uses the default region code.
    public var defaultRegion = PhoneNumberKit.defaultRegionCode() {
        didSet {
            partialFormatter?.defaultRegion = defaultRegion
        }
    }
    
    public var withPrefix: Bool = true {
        didSet {
            partialFormatter?.withPrefix = withPrefix
            if withPrefix == false {
                self.keyboardType = UIKeyboardType.numberPad
            }

    }
    
    //MARK: Status
    
    public var currentRegion: String {
        get {
            return partialFormatter.currentRegion
        }
    }
    public var isValidNumber: Bool {
        get {
            let rawNumber = self.text ?? String()
            do {
                let _ = try phoneNumberKit.parse(rawNumber, withRegion: currentRegion)
                return true
            } catch {
                return false
            }
        }
    }
    
    //MARK: Lifecycle
    
    /**
     Init with frame
     
     - parameter frame: UITextfield F
     
     - returns: UITextfield
     */
    override public init(frame:CGRect)
    {
        self.partialFormatter = PartialFormatter(phoneNumberKit: phoneNumberKit, defaultRegion: defaultRegion, withPrefix: withPrefix)
        super.init(frame:frame)
        self.setup()
    }
    
    /**
     Init with coder
     
     - parameter aDecoder: decoder
