fjcaetano / NSStringMask

NSStringMask allows you to apply masks or formats to NSStrings using NSRegularExpression to input your format.
http://fjcaetano.github.io/NSStringMask/
MIT License
241 stars 36 forks source link

mask nil #2

Closed aleufms closed 10 years ago

aleufms commented 11 years ago

I think it's better that a textfield with mask = nil would have a behavior equals a normal uitextfield. So, it can be a drop in replacement for it.

fjcaetano commented 11 years ago

There's no point in assigning a nil mask to an UITextFieldMask. It will work similarly to a regular UITextField but it will actually be slower because of the preprocessing there is before sending forward the messages to the textfield's delegate.

Can you give me a real example of why this could be interesting? I honestly can't see how this could happen.

aleufms commented 11 years ago

It's because I have a base class for all input views. I have a base class called MYTextField : UITextField, so I can set a lot of common properties (that not supported in appearance framework) for all textfields in my application. I want to use masks in some fields, so I would subclass MYTextField : UITextFieldMask instead UITextField and set mask only on textfields that require the mask.

You can check if mask is nil and ignore the preprocessing. It will have an overhead, but I think it is not critical.

fjcaetano commented 11 years ago

I'll see what I can do, but I won't be able to touch this code this week. If you need it ASAP, feel free to fork the project and try to tweak it.

If you succeed, do a pull-request and I'll review it.

fjcaetano commented 10 years ago

I added ARC support and your request.

Check it out: 7db83bff71c889682694c422da5327c0658a7286

aleufms commented 10 years ago

Oh, nice. Thank you. Valeu!!!