artemkrachulov / AKMaskField

Swift plugin which allow add mask to input field
MIT License
346 stars 131 forks source link

Crashes on setting a placeholder without a mask #30

Open x128 opened 7 years ago

x128 commented 7 years ago

fatal error: unexpectedly found nil while unwrapping an Optional value

  * frame #1: AKMaskField.moveCarret(self=0x000000010e24de00) -> () + 320 at AKMaskField.swift:369
    frame #2: AKMaskField.refreshMask(self=0x000000010e24de00) -> () + 980 at AKMaskField.swift:238
    frame #3: AKMaskField.placeholder.didset(oldValue=some, self=0x000000010e24de00) + 96 at AKMaskField.swift:277
    frame #4: AKMaskField.placeholder.setter(newValue="ММ / ГГГГ", self=0x000000010e24de00) + 540 at AKMaskField.swift:0
    frame #5: CustomDateField. ...(closure #1) + 120 at CustomDateField.swift:28

The problem is pretty clear, There are no maskBlocks here:

        switch maskStatus {
        case .clear       : position = maskBlocks.first!.templateRange.location