Reputation: 26385
I'm facing that crash while keyboard is shown. As suggested in Apple docs I'm listening to notification sent from keyboard to adjust the position of a textview that it would be covered by keyboard. In simulator session and in debugging session at the first time the app is running and only the first time when I tap on the texfield the app crashes, in the console I've got this message:
-[UITextMagnifierCaret keyboardWasShown:]: unrecognized selector sent to instance 0x3ee2e0 2012-05-02 07:17:49.929 X-X-X-X[316:707] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextMagnifierCaret keyboardWasShown:]: unrecognized selector sent to instance 0x3ee2e0'
Here are few clues:
Upvotes: 1
Views: 711
Reputation: 6707
You registered some object as an observer, then later deallocated the object, but the observer was still pointing to that memory location. The exception about the UITextMagnifierCaret is probably because the memory location once allocated to your observer is now allocated to a UITextMagnifierCaret object you don't manage, and that doesn't respond to the keyboard notification.
Using ARC may have helped avoiding this kind of issue. Generally, make sure to nil or remove any pointers to an object you're about to release manually.
Upvotes: 1