Reputation: 150
Swift app crashes when typing on every textfield
Everything goes unless a textfield get tapped. When I tap textfields in the same view all it's ok but when I change view and so have another controller and tap in any textfield app crash.
Stack trace:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance
Upvotes: 0
Views: 678
Reputation: 1232
It looks like your UITextField
has some value (maybe textField.text
) that has not the correct type. The length
method is often used on NSString
and causes crashed when used on some others types that do not implement it (e.g. NSNumber
).
I advise you to double check your UITextField
to see if all your values are those that are meant to be.
EDIT : I just re-read your post. It looks like you are passing nil or an NSNull object to textField.text
(maybe in textFieldDidBeginEditing
which causes the crash. Change this to pass a String and it should fix it.
Upvotes: 0