Andrea
Andrea

Reputation: 26385

Crash while showing the keyboard only the first time app run

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:

  1. the keyboard was show before in another section
  2. the crash nevr happens again if it is already happen
  3. it seems to show up only during debugging on sim and device, but not in ad-hoc
  4. My ios version is 5.1
  5. UITextMagnifierCaret is not a class of the app, but i guess is the magnigfing class

Upvotes: 1

Views: 711

Answers (1)

JP Hribovsek
JP Hribovsek

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

Related Questions