User input masking library repo.

Overview

Input Mask

Awesome Version Badge SPM compatible Carthage compatible license Build Status codebeat badge

PlatformAndroidiOSmacOS

Input Mask

Migration Guide: v.6

This update brings breaking changes. Namely, the autocomplete flag is now a part of the CaretGravity enum, thus the Mask::apply call is now single-argument, as all the necessary information is included into the CaretString structure.

v.6 introduces the «autoskip» feature, which allows the cursor to jump over formatting blocks of symbols in the middle of the text as if they were a single char when hitting Backspace, and this feature also allows to trim formatting characters on backspacing at the end of the line.

Make sure to take a look at our CHANGELOG.

Description

Input Mask is an Android & iOS native library allowing to format user input on the fly.

The library provides you with a text field listener; when attached, it puts separators into the text while user types it in, and gets rid of unwanted symbols, all according to custom predefined pattern.

This allows to reformat whole strings pasted from the clipboard, e.g. turning pasted 8 800 123-45-67 into
8 (800) 123 45 67.

Each pattern allows to extract valuable symbols from the entered text, returning you the immediate result with the text field listener's callback when the text changes. Such that, you'll be able to extract 1234567 from 8 (800) 123 45 67 or 19991234567 from 1 (999) 123 45 67 with two different patterns.

All separators and valuable symbol placeholders have their own syntax. We call such patterns "masks".

Mask examples:

  1. International phone numbers: +1 ([000]) [000] [00] [00]
  2. Local phone numbers: ([000]) [000]-[00]-[00]
  3. Names: [A][-----------------------------------------------------]
  4. Text: [A…]
  5. Dates: [00]{.}[00]{.}[9900]
  6. Serial numbers: [AA]-[00000099]
  7. IPv4: [099]{.}[099]{.}[099]{.}[099]
  8. Visa card numbers: [0000] [0000] [0000] [0000]
  9. MM/YY: [00]{/}[00]
  10. UK IBAN: GB[00] [____] [0000] [0000] [0000] [00]

Questions & Issues

Check out our wiki for further reading.
Please also take a closer look at our Known issues section before you incorporate our library into your project.

For your bugreports and feature requests please file new issues as usually.

Should you have any questions, search for closed issues or open new ones at StackOverflow with the input-mask tag.

We also have a community-driven cookbook of recipes, be sure to check it out, too.

Installation

CocoaPods

pod 'InputMask'

Carthage

git "https://github.com/RedMadRobot/input-mask-ios.git"

Swift Package Manager

dependencies: [
    .Package(url: "https://github.com/RedMadRobot/input-mask-ios", majorVersion: 6)
]

Manual

  1. git clone this repository;
  2. Add InputMask.xcodeproj into your project/workspace;
  3. Go to your target's settings, add InputMask.framework under the Embedded Binaries section
  4. For ObjC projects:
    • (~Xcode 8.x) make sure Build Options has Embedded Content Contains Swift Code enabled;
    • import bridging header.

Known issues

UITextFieldTextDidChange notification and target-action editingChanged event

UITextField with assigned MaskedTextFieldDelegate object won't issue UITextFieldTextDidChange notifications and editingChanged control events. This happens due to the textField(_:shouldChangeCharactersIn:replacementString:) method implementation, which always returns false.

Consider using following workaround in case if you do really need to catch editing events:

class NotifyingMaskedTextFieldDelegate: MaskedTextFieldDelegate {
    weak var editingListener: NotifyingMaskedTextFieldDelegateListener?
    
    override func textField(
        _ textField: UITextField,
        shouldChangeCharactersIn range: NSRange,
        replacementString string: String
    ) -> Bool {
        defer {
            self.editingListener?.onEditingChanged(inTextField: textField)
        }
        return super.textField(textField, shouldChangeCharactersIn: range, replacementString: string)
    }
}


protocol NotifyingMaskedTextFieldDelegateListener: class {
    func onEditingChanged(inTextField: UITextField)
}

Please, avoid at all costs sending SDK events and notifications manually.

Carthage vs. IBDesignables, IBInspectables, views and their outlets

Interface Builder struggles to support modules imported in a form of a dynamic framework. For instance, custom views annotated as IBDesignable, containing IBInspectable and IBOutlet fields aren't recognized properly from the drag'n'dropped *.framework.

In case you are using our library as a Carthage-built dynamic framework, be aware you won't be able to easily wire your MaskedTextFieldDelegate objects and their listeners from storyboards in your project. There is a couple of workarounds described in the corresponding discussion, though.

Also, consider filing a radar to Apple, like this one.

Cut action doesn't put text into the pasteboard

When you cut text, characters get deleted yet you won't be able to paste them somewhere as they aren't actually in your pasteboard.

iOS hardwires UIMenuController's cut action to the UITextFieldDelegate's textField(_:shouldChangeCharactersIn:replacementString:) return value. This means "Cut" behaviour actually depends on the ability to edit the text.

Bad news are, our library returns false in textField(_:shouldChangeCharactersIn:replacementString:), and heavily depends on this false. It would require us to rewrite a lot of logic in order to change this design, and there's no guarantee we'll be able to do so.

Essentially, there's no distinct way to differentiate "Cut selection" and "Delete selection" actions on the UITextFieldDelegate side. However, you may consider using a workaround, which will require you to subclass UITextField overriding its cut(sender:) method like this:

class UITextFieldMonkeyPatch: UITextField {
    override func cut(_ sender: Any?) {
        copy(sender)
        super.cut(sender)
    }
}

From our library perspective, this looks like a highly invasive solution. Thus, in the long term, we are going to investigate a "costly" method to bring the behaviour matching the iOS SDK logic. Yet, here "long term" might mean months.

Incorrect cursor position after pasting

Shortly after new text is being pasted from the clipboard, every UITextInput receives a new value for its selectedTextRange property from the system. This new range is not consistent with the formatted text and calculated caret position most of the time, yet it's being assigned just after set caretPosition call.

To ensure correct caret position is set, it might be assigned asynchronously (presumably after a vanishingly small delay), if caret movement is set to be non-atomic; see MaskedTextFieldDelegate.atomicCursorMovement property.

MaskedTextInputListener

In case you are wondering why do we have two separate UITextFieldDelegate and UITextViewDelegate implementations, the answer is simple: prior to iOS 11 UITextField and UITextView had different behaviour in some key situations, which made it difficult to implement common logic.

Both had the same bug with the UITextInput.beginningOfDocument property, which rendered impossible to use the generic UITextInput protocol UITextField and UITextView have in common.

Since iOS 11 most of the things received their fixes (except for the UITextView edge case). In case your project is not going to support anything below 11, consider using the modern MaskedTextInputListener.

References

The list of projects that are using this library which were kind enough to share that information.

Feel free to add yours below.

Special thanks

These folks rock:

License

The library is distributed under the MIT LICENSE.

Comments
  • 12.2 Developer beta 2 Crash - initWithCoder error

    12.2 Developer beta 2 Crash - initWithCoder error

    Prerequisites

    • [X ] Put an X between the brackets on this line if you have done all of the following:
      • read our Wiki;
      • read the entire Known issues section;
      • checked that my issue isn't already filled;
      • searched StackOverflow's input-mask tag for similar problems.

    Describe the bug

    I noticed that after using ViewController that used a TextField utilising the input mask, the App would crash. This was strange since the that exact page worked the day before and I had not made any changes to that view controller or UI in storyboard - The only change I had made was in my enviroment: I had build the app with xCode 10 Beta 2 to be able to run/test the app on my iphone that is running the beta version of iOS 12.2 Developer beta 2. I decided to build out a new view controller by bringing over all the controlls from the current page one by one and seeing when it breaks - it only broke the moment I add the InputMask Delegate Objects.

    Steps to reproduce the behaviour:

    Have a page with a InputMask Textfield setup - build app for iOS 12.2 Developer beta 2 (using xCode 10 beta 2)

    Expected behaviour Input Mask functions

    Actual behaviour App crashes: error produced: Terminating app due to uncaught exception 'NSGenericException', reason: 'This coder requires that replaced objects be returned from initWithCoder:'

    That is the core of the problem, however, the rest of the error call stack can be found here:

    *** First throw call stack: ( 0 CoreFoundation 0x0000000108ca072b __exceptionPreprocess + 331 1 libobjc.A.dylib 0x000000010768eac5 objc_exception_throw + 48 2 CoreFoundation 0x0000000108ca0585 +[NSException raise:format:] + 197 3 UIFoundation 0x000000010f47e89c UINibDecoderDecodeObjectForValue + 827 4 UIFoundation 0x000000010f47eaf9 UINibDecoderDecodeObjectForValue + 1432 5 UIFoundation 0x000000010f47e554 -[UINibDecoder decodeObjectForKey:] + 251 6 UIKitCore 0x0000000111825e90 -[UIViewController initWithCoder:] + 1021 7 DumaPay Consumer iOS 0x00000001055bde66 $s20DumaPay_Consumer_iOS25TestAddCardViewControllerC5coderACSgSo7NSCoderC_tcfc + 2214 8 DumaPay Consumer iOS 0x00000001055bdf2f $s20DumaPay_Consumer_iOS25TestAddCardViewControllerC5coderACSgSo7NSCoderC_tcfcTo + 47 9 UIKitCore 0x0000000111aaae89 -[UIClassSwapper initWithCoder:] + 246 10 UIFoundation 0x000000010f47e852 UINibDecoderDecodeObjectForValue + 753 11 UIFoundation 0x000000010f47e554 -[UINibDecoder decodeObjectForKey:] + 251 12 UIKitCore 0x0000000111aaf4d1 -[UIRuntimeConnection initWithCoder:] + 178 13 UIFoundation 0x000000010f47e852 UINibDecoderDecodeObjectForValue + 753 14 UIFoundation 0x000000010f47eaf9 UINibDecoderDecodeObjectForValue + 1432 15 UIFoundation 0x000000010f47e554 -[UINibDecoder decodeObjectForKey:] + 251 16 UIKitCore 0x0000000111aacd81 -[UINib instantiateWithOwner:options:] + 1216 17 UIKitCore 0x0000000111fc5290 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181 18 DumaPay Consumer iOS 0x0000000105623ea9 $s20DumaPay_Consumer_iOS28AddCardScannerViewControllerC010goToManualfE004cardG6ResultySo0b15CardsRecognizerN0CSg_tF + 249 19 DumaPay Consumer iOS 0x0000000105623d2e $s20DumaPay_Consumer_iOS28AddCardScannerViewControllerC02oneF15ManuallyClicked6senderyyp_tF + 62 20 DumaPay Consumer iOS 0x0000000105623d8c $s20DumaPay_Consumer_iOS28AddCardScannerViewControllerC02oneF15ManuallyClicked6senderyyp_tFTo + 76 21 UIKitCore 0x0000000111e2e834 -[UIApplication sendAction:to:from:forEvent:] + 83 22 UIKitCore 0x00000001118845b5 -[UIControl sendAction:to:forEvent:] + 67 23 UIKitCore 0x00000001118848d2 -[UIControl _sendActionsForEvents:withEvent:] + 450 24 UIKitCore 0x0000000111883888 -[UIControl touchesEnded:withEvent:] + 583 25 UIKitCore 0x0000000111e6751e -[UIWindow _sendTouchesForEvent:] + 2547 26 UIKitCore 0x0000000111e68c02 -[UIWindow sendEvent:] + 4079 27 UIKitCore 0x0000000111e47346 -[UIApplication sendEvent:] + 356 28 UIKitCore 0x0000000111f178c3 __dispatchPreprocessedEventFromEventQueue + 3232 29 UIKitCore 0x0000000111f1a1e9 __handleEventQueueInternal + 5911 30 CoreFoundation 0x0000000108c07c11 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 31 CoreFoundation 0x0000000108c07493 __CFRunLoopDoSources0 + 243 32 CoreFoundation 0x0000000108c01b4f __CFRunLoopRun + 1231 33 CoreFoundation 0x0000000108c01332 CFRunLoopRunSpecific + 626 34 GraphicsServices 0x000000010f1222fe GSEventRunModal + 65 35 UIKitCore 0x0000000111e2d1d2 UIApplicationMain + 140 36 DumaPay Consumer iOS 0x0000000105609bdb main + 75 37 libdyld.dylib 0x000000010a883861 start + 1 38 ??? 0x0000000000000001 0x0 + 1 )

    Platform information

    • OS version: iOS 12.2 beta 2
    • Library version: 4.1.0
    • Language: Swift 4.2
    bug 
    opened by SteynMarnus 11
  • Wrong mask attached after editing

    Wrong mask attached after editing

    I have following masks set: self.login.affineFormats = [ "{+7} ([000]) [000] [00] [00]", "{8} ([000]) [000]-[00]-[00]" ]

    When i type a phone number with +7 mask and then edit the value within ([000]) mask switches to 8 instead of +7 and then 7 is put inside ([000])

    enhancement 
    opened by MrJox 11
  • Brazilian Phones

    Brazilian Phones

    Here in brazil we have a problem that cell phones there are 9 digits and landlines have 8 digits. We can solve that using affineFormats from PolyMaskTextFieldDelegate but there is a problem, that is not automatically.

    self.phonePolyMaskTextFieldDelegate?.affineFormats = [ "([00]) [00000]-[0000]", "([00]) [0000]-[0000]"]

    Im using like this. But if i have an 8 digits phone, i do need to type the "-" to force the textfield be 8 digits. Is there any way to do it automatically? Like, if my phone have 8 digits, it stays with the mask ([00]) [0000]-[0000] and if i need to put 9 digits the "-" automatically changes.

    question 
    opened by cs-joao-souza 9
  • Обрыв событийной модели при изменении текста

    Обрыв событийной модели при изменении текста

    Добрый день. Во первых хочется сказать спасибо за отличную библиотеку.

    Столкнулся с тем, что MaskedTextFieldDelegate в методе

    open func textField(
            _ textField: UITextField,
            shouldChangeCharactersIn range: NSRange,
            replacementString string: String) -> Bool {
            
            let extractedValue: String
            let complete:       Bool
            
            if isDeletion(
                inRange: range,
                string: string
            ) {
                (extractedValue, complete) = self.deleteText(inRange: range, inField: textField)
            } else {
                (extractedValue, complete) = self.modifyText(inRange: range, inField: textField, withText: string)
            }
            
            self.listener?.textField?(
                textField,
                didFillMandatoryCharacters: complete,
                didExtractValue: extractedValue
            )
            let _ = self.listener?.textField?(textField, shouldChangeCharactersIn: range, replacementString: string)        
            return false
        }
    

    всегда возвращает false, что не дает сработать событиям ни через NotificationCenter ни через actions for controlEvents. хотя в этом методе так или иначе изменится свойство text у textField.

    Возможно решение не самое лучшее, но как временную заплатку у себя поправил, добавив перед возвратом вызов поста события в NotificationCenter и вызов actions для события editingChanged

    open func textField(
            _ textField: UITextField,
            shouldChangeCharactersIn range: NSRange,
            replacementString string: String) -> Bool {
            
            let extractedValue: String
            let complete:       Bool
            
            if isDeletion(
                inRange: range,
                string: string
            ) {
                (extractedValue, complete) = self.deleteText(inRange: range, inField: textField)
            } else {
                (extractedValue, complete) = self.modifyText(inRange: range, inField: textField, withText: string)
            }
            
            self.listener?.textField?(
                textField,
                didFillMandatoryCharacters: complete,
                didExtractValue: extractedValue
            )
            let _ = self.listener?.textField?(textField, shouldChangeCharactersIn: range, replacementString: string)
            
            NotificationCenter.default.post(name: .UITextFieldTextDidChange, object: textField)
            textField.sendActions(for: .editingChanged)
            
            return false
        }
    

    Что думаете на этот счет?

    enhancement question 
    opened by ghost 8
  • Crash delegate

    Crash delegate

    Prerequisites

    • [X ] Put an X between the brackets on this line if you have done all of the following:
      • read our Wiki;
      • read the entire Known issues section;
      • checked that my issue isn't already filled;
      • searched StackOverflow's input-mask tag for similar problems.

    Describe the bug

    I have a crash related to UITextView delegate. I'm not sure it's related to your library thought, I only use it with your library and the bug appeared in the same version I updated the library.

    Here is a stack trace:

    Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0x2329ca3a8 __exceptionPreprocess 1 libobjc.A.dylib 0x231bcfd00 objc_exception_throw 2 CoreFoundation 0x2328e29f8 -[NSOrderedSet initWithSet:copyItems:] 3 CoreFoundation 0x2329cfd54 forwarding 4 CoreFoundation 0x2329d1b50 _CF_forwarding_prep_0 5 UIKitCore 0x25ffdffc8 -[UITextView keyboardInputChangedSelection:] 6 UIKitCore 0x25ff518cc -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) notifyKeyboardSelectionChanged] 7 UIKitCore 0x25ff3c54c -[UITextNonEditableInteraction oneFingerTapInUneditable:] 8 UIKitCore 0x25f8ac420 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] 9 UIKitCore 0x25f8b48e0 _UIGestureRecognizerSendTargetActions 10 UIKitCore 0x25f8b21dc _UIGestureRecognizerSendActions 11 UIKitCore 0x25f8b16b0 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] 12 UIKitCore 0x25f8a5474 _UIGestureEnvironmentUpdate 13 UIKitCore 0x25f8a4ba0 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] 14 UIKitCore 0x25f8a4970 -[UIGestureEnvironment _updateForEvent:window:] 15 UIKitCore 0x25fcd7cac -[UIWindow sendEvent:] 16 UIKitCore 0x25fcb6f50 -[UIApplication sendEvent:] 17 UIKitCore 0x25fd82150 __dispatchPreprocessedEventFromEventQueue 18 UIKitCore 0x25fd8490c __handleEventQueueInternal 19 UIKitCore 0x25fd7d9c4 __handleHIDEventFetcherDrain 20 CoreFoundation 0x23295a444 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION 21 CoreFoundation 0x23295a3c0 __CFRunLoopDoSource0 22 CoreFoundation 0x232959c7c __CFRunLoopDoSources0 23 CoreFoundation 0x232954950 __CFRunLoopRun 24 CoreFoundation 0x232954254 CFRunLoopRunSpecific 25 GraphicsServices 0x234b93d8c GSEventRunModal 26 UIKitCore 0x25fc9c4c0 UIApplicationMain

    Steps to reproduce the behaviour:

    The crash happens rarely. Tried every gesture or input on all my textview ^^ as the stack trace doesn't contain any ref to my code.

    Platform information

    • OS version: 9.0+
    • Library version: 4.1.1+
    • Language: 5.0.1

    Additional context I use RxSwift/RxCocoa which can swizzle delegates thought each place I use this lib Rx is not used.

    circumstances clarification 
    opened by AlexisQapa 6
  • Ability to set an empty mask

    Ability to set an empty mask

    As I was making my inputs generics so all could take a mask I defaulted the mask to "" (the default in the lib code) and I all inputs stopped accepting chars. Think the empty mask should allow any char or the default should be an allow all mask.

    question 
    opened by AlexisQapa 6
  • Blank space issues

    Blank space issues

    I'm facing two issues regarding blank space.

    1. I have this mask for credit card: "[0000] [0000] [0000] [0000] [999]" but the main problem is when user finishes typing mandatory numbers, it still says is not completed because the user didn't type the blank space before [999]. How can I fix this issue?

    2. I have this mask for name input: [A…] but it doesn't allow me to input blank space, and it seems there is no symbol for that. I even tried to create my custom notation for blank space but no success. How can I allow at least one letter and optional blank spaces?

    Thanks for this awesome library!

    question feature request 
    opened by caioremedio 6
  • Numeric Mask right to left

    Numeric Mask right to left

    Hello, I need to implement a simple decimal mask with the following format:

    999.999.999

    When I type my text right now, I get the following result:

    123.456.78 (left to right)

    I need to type my numbers and the mask to work from right to left, so when I type those numbers I get the following result:

    12.345.678

    Is this possible?

    feature request 
    opened by joaolongo 6
  • Get original string

    Get original string

    How to get original string? For example, i have mask {(123)}-[000] and text field text is "(123)456, i want to get what exactly user enter, is that case - 456.

    question 
    opened by beltik 6
  • Fails to copile with Carthage

    Fails to copile with Carthage

    Cartfile:

    git "https://github.com/RedMadRobot/input-mask-ios.git"
    

    Command: carthage update --platform ios

    Output:

    *** Building scheme "InputMask" in InputMask.xcodeproj
    Build Failed
    	Task failed with exit code 65:
    	/usr/bin/xcrun xcodebuild -project /Users/johnzakharov/Desktop/Xcode/crediton-ios/Carthage/Checkouts/input-mask-ios/Source/InputMask/InputMask.xcodeproj -scheme InputMask -configuration Release -derivedDataPath /Users/johnzakharov/Library/Caches/org.carthage.CarthageKit/DerivedData/input-mask-ios/3.0.0 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build (launched in /Users/johnzakharov/Desktop/Xcode/crediton-ios/Carthage/Checkouts/input-mask-ios)
    
    This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/hz/_y3bdbvn025bv6gk1xqq1_jm0000gn/T/carthage-xcodebuild.IgDgmm.log
    

    Log file (inputmask part):

    /usr/bin/xcrun xcodebuild -project /Users/johnzakharov/Desktop/Xcode/crediton-ios/Carthage/Checkouts/input-mask-ios/Source/InputMask/InputMask.xcodeproj -scheme InputMask -configuration Release -derivedDataPath /Users/johnzakharov/Library/Caches/org.carthage.CarthageKit/DerivedData/input-mask-ios/3.0.0 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build (launched in /Users/johnzakharov/Desktop/Xcode/crediton-ios/Carthage/Checkouts/input-mask-ios)User defaults from command line:
        IDEDerivedDataPathOverride = /Users/johnzakharov/Library/Caches/org.carthage.CarthageKit/DerivedData/input-mask-ios/3.0.0
    
    Build settings from command line:
        BITCODE_GENERATION_MODE = bitcode
        CARTHAGE = YES
        CODE_SIGN_IDENTITY = 
        CODE_SIGNING_REQUIRED = NO
        ONLY_ACTIVE_ARCH = NO
        SDKROOT = iphoneos10.3
    
    === CLEAN TARGET InputMask OF PROJECT InputMask WITH CONFIGURATION Release ===
    
    Check dependencies
    “Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
    “Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
    
    ** CLEAN FAILED **
    
    
    The following build commands failed:
    	Check dependencies
    (1 failure)
    === BUILD TARGET InputMask OF PROJECT InputMask WITH CONFIGURATION Release ===
    
    Check dependencies
    “Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
    “Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
    
    ** BUILD FAILED **
    
    
    The following build commands failed:
    	Check dependencies
    (1 failure)
    
    circumstances clarification 
    opened by fnc12 6
  • Strong reference

    Strong reference

    Is there a way for InputMask to work as a weak reference? Because when I pop my viewController it causes memory leak due to the strong reference. But if I set it to weak reference, mask isn't applied

    opened by MrJox 5
  • Poor performance when user types fast

    Poor performance when user types fast

    Prerequisites

    • [x] Put an X between the brackets on this line if you have done all of the following:
      • read our Wiki;
      • read the entire Known issues section;
      • checked that my issue isn't already filled;
      • searched StackOverflow's input-mask tag for similar problems.

    Describe the bug

    Hi @taflanidi First of all I wanted to say thank you for the great lib!

    However, I found, that if I type really fast, then the input is handled slower, than I typing.

    Steps to reproduce the behaviour:

    1. Clone the project
    2. Change value in userDefinedRuntimeAttribute to [A…] in sample app
    3. Run sample app
    4. try to type any random symbols but do it really fast 🙂

    Expected behaviour

    User should type as fast as he can and no lags/delays should occur (as when using a normal UITextField)

    Actual behaviour

    In the beginning I can type in real time mode. However after given time (when I typed quite a lot of characters) the process becomes slower and slower and at some point you can stop typing, but you will see, how new characters still appears.

    Screenshots

    https://user-images.githubusercontent.com/22820318/158359490-3edf5610-5852-4b29-baa8-941412a05843.mov

    After the sixth second I don't type anymore, but the characters continue to appear. UI thread FPS goes to 0.

    Platform information

    • OS version: 15.2
    • Library version: 6.1.0
    • Language: Swift 5
    • Device (if bug is device-specific): I think it's not device-specific, because the issues was reproducible on iPhone 7 (real device) too.

    Additional context

    I didn't dig into the implementation, so I can not say, where the performance drop occurs 😔

    opened by kirillzyusko 0
  • Number Formatting (Thousand Separator)

    Number Formatting (Thousand Separator)

    Prerequisites

    • [X] Put an X between the brackets on this line if you have done all of the following:
      • read our Wiki;
      • read the entire Known issues section;
      • checked that my feature request isn't already filled;
      • searched StackOverflow's input-mask tag for similar problems.

    Summary

    Hi! I stumbled upon this library in my journey to format numbers correctly for the user.

    I want the user to enter a number, which will be formatted with decimal points and thousand separators:

    | Input | Output | |---------------|-----------------| | 1 | 1 | | 12 | 12 | | 123 | 123 | | 1234 | 1,234 | | 12345 | 12,345 | | 123456 | 123,456 | | 1234567 | 1,234,567 | | 12345678 | 12,345,678 | | 12345678.5 | 12,345,678.5 | | 12345678.59 | 12,345,678.59 | | 12345678.594 | 12,345,678.594 | | 12345678.5948 | 12,345,678.5948 | | 0.5 | 0.5 |

    Motivation

    Number Inputs (Currency, Crypto Amount)

    Describe the solution you'd like

    I'd like to have a mask that is able to format those numbers correctly.

    Describe alternatives you've considered

    I tried this: [099].[999].[999].[999].[999].[999],[999999999999]

    Is this possible with this library? Any help appreciated!

    opened by mrousavy 0
  • Delete .swift-version

    Delete .swift-version

    opened by RomanPodymov 2
  • How to define ${dynamic amount }/month in input mask

    How to define ${dynamic amount }/month in input mask

    the amount should be dynamic it may be 1 or 10 or 100 or 1000 ...etc, i defined it like "$[0000]/month"....but it not works for me it showing "/month" after entering 4 digits and also it did not taking more than 4 digits

    opened by Joshig99 0
  • [!] Unable to determine Swift version for the following pods

    [!] Unable to determine Swift version for the following pods

    Describe the bug

    [!] Unable to determine Swift version for the following pods:
    
    - `InputMask` does not specify a Swift version and none of the targets (`AppName`) integrating 
    it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` 
    attribute in at least one of the targets that integrate this pod.
    

    Additional context I believe including a swift_version to InputMask.podspec will resolve the problem.

    opened by dustinyoste 0
Releases(6.0.0)
  • 6.0.0(Mar 16, 2020)

    Removed:

    • Mask::apply(), the autocomplete flag

    This flag is now a part of the CaretGravity.forward enum case.

    Added:

    • CaretGravity.forward, the autocomplete flag
    • CaretGravity.backward, the autoskip flag
    Source code(tar.gz)
    Source code(zip)
Owner
red_mad_robot
knows its onions in mobile application development
red_mad_robot
Croc is a swift emoji string parsing library

Croc is a library for parsing emojis on iOS. It provides a simple and lightweight interface for detecting, generating, categorizing and managing emoji characters, making emoji-powered features an easy task for developers.

Joe Kalash 127 Nov 20, 2022
A library for formatting strings on iOS and macOS

Sprinter Introduction What? Why? How? Usage Installation Integration Localization Thread Safety Advanced Usage Introduction What? Sprinter is a librar

Nick Lockwood 168 Feb 6, 2022
SwiftVerbalExpressions is a Swift library that helps to construct difficult regular expressions

SwiftVerbalExpressions Swift Regular Expressions made easy SwiftVerbalExpressions is a Swift library that helps to construct difficult regular express

null 582 Jun 29, 2022
🌭 Mustard is a Swift library for tokenizing strings when splitting by whitespace doesn't cut it.

Mustard ?? Mustard is a Swift library for tokenizing strings when splitting by whitespace doesn't cut it. Quick start using character sets Foundation

Mathew Sanders 695 Nov 11, 2022
Swift markdown library

Markdown ![Swift version](https://img.shields.io/badge/Swift-2.1 | 2.2-blue.svg) ![GitHub license](https://img.shields.io/badge/license-LGPL v3-green.

Crossroad Labs 79 Oct 9, 2022
A simple library for building attributed strings, for a more civilized age.

Veneer A simple library for building attributed strings, for a more civilized age. Veneer was created to make creating attributed strings easier to re

Wess Cope 26 Dec 27, 2022
SZMentionsSwift is a lightweight mentions library for iOS.

SZMentionsSwift is a lightweight mentions library for iOS. This library was built to assist with the adding, removing and editing of a mention within a textview.

Steven Zweier 122 Dec 12, 2022
Lightweight library to set an Image as text background. Written in swift.

![](https://img.shields.io/badge/Swift 2-compatible-4BC51D.svg?style=flat-square) Simple and light weight UIView that animate text with an image. Demo

Lucas Ortis 552 Sep 9, 2022
A simple library that provides standard Unicode emoji support across all platforms

Twitter Emoji (Twemoji) A simple library that provides standard Unicode emoji support across all platforms. Twemoji v13.1 adheres to the Unicode 13.0

Twitter 15k Jan 8, 2023
iOS port from libphonenumber (Google's phone number handling library)

libPhoneNumber for iOS NBPhoneNumberUtil NBAsYouTypeFormatter ARC only Update Log https://github.com/iziz/libPhoneNumber-iOS/wiki/Update-Log Issue You

iziz 2.3k Jan 3, 2023
A Cross-Platform String and Regular Expression Library written in Swift.

Guitar ?? A Cross-Platform String and Regular Expression Library written in Swift. About This library seeks to add common string manipulation function

Arthur Ariel Sabintsev 659 Dec 27, 2022
A lightweight fuzzy-search library, with zero dependencies

Fuse What is Fuse? Fuse is a super lightweight library which provides a simple way to do fuzzy searching. Usage Example 1 let fuse = Fuse() let result

Kiro Risk 864 Dec 29, 2022
Swift emoji string parsing library

Croc is a library for parsing emojis on iOS. It provides a simple and lightweight interface for detecting, generating, categorizing and managing emoji

Joe Kalash 125 Sep 27, 2021
Input Mask is an Android & iOS native library allowing to format user input on the fly.

Migration Guide: v.6 This update brings breaking changes. Namely, the autocomplete flag is now a part of the CaretGravity enum, thus the Mask::apply c

red_mad_robot 548 Dec 20, 2022
Input Validation Done Right. A Swift DSL for Validating User Input using Allow/Deny Rules

Valid Input Validation Done Right. Have you ever struggled with a website with strange password requirements. Especially those crazy weird ones where

Mathias Quintero 37 Nov 3, 2022
A smart and easy-to-use image masking and cutout SDK for mobile apps.

TinyCrayon SDK for iOS A smart and easy-to-use image masking and cutout SDK for mobile apps. TinyCrayon SDK provides tools for adding image cutout and

null 1.8k Dec 30, 2022
A Pinterest-like segment control with masking animation.

PinterestSegment A Pinterest-like segment control with masking animation. Requirements iOS 8.0+ Xcode 9.0 Swift 4.0 Installation CocoaPods You can use

TBXark 672 Dec 20, 2022
Drop in user input validation for your iOS apps.

Validator Validator is a user input validation library written in Swift. It's comprehensive, designed for extension, and leaves the UI up to you. Here

Adam Waite 1.4k Dec 29, 2022
A network extension app to block a user input URI. Meant as a network extension filter proof of concept.

URIBlockNE A network extension app to block a user input URI. Meant as a network extension filter proof of concept. This is just a research effort to

Charles Edge 5 Oct 17, 2022
The Big List of Naughty Strings is a list of strings which have a high probability of causing issues when used as user-input data.

The Big List of Naughty Strings is a list of strings which have a high probability of causing issues when used as user-input data. I have put together

Romain Pouclet 589 Sep 7, 2022