Hi all... I'm working on an iPad (universal) app that is giving me some trouble. We have a kind of "floating" window that has a close button on the side. Its contents are gathered from a UIViewController instance that have a couple UITextFields on a tableview. The issue comes up when doing multiple touches around on the screen, and the user happens to close the Window during some delegate calls that sometimes get delayed by the system (tableview datasource and delegate calls, textfield delegate calls).
Most of the issues went away when I carefully set the delegates and datasources to nil on the view controller's dealloc method. But one of them persists: if I try to close the window and simultaneously try to begin editing a text field, I get a message sent to deallocated instance
Code:
*** -[ViewController respondsToSelector:]: message sent to deallocated instance 0x4240ba0
And this is the call stack :
Code:
#0 0x34d4f910 in ___forwarding___ ()
#1 0x34d4f860 in __forwarding_prep_0___ ()
#2 0x300d6ae4 in -[UITextField canBecomeFirstResponder] ()
#3 0x30032ce8 in -[UIResponder becomeFirstResponder] ()
#4 0x300d69cc in -[UITextInteractionAssistant setFirstResponderIfNecessary] ()
#5 0x300d642c in -[UITextInteractionAssistant oneFingerTap:] ()
#6 0x34d44bbe in -[NSObject(NSObject) performSelector:withObject:] ()
#7 0x300c63d2 in -[UIGestureRecognizer _updateGestureWithEvent:] ()
#8 0x300c618a in -[UIGestureRecognizer _delayedUpdateGesture] ()
#9 0x3002d7b0 in _UIGestureRecognizerUpdateObserver ()
#10 0x300451de in _UIGestureRecognizerUpdateGesturesFromSendEvent ()
#11 0x30044fe0 in -[UIWindow _sendGesturesForEvent:] ()
#12 0x30044c0a in -[UIWindow sendEvent:] ()
#13 0x3002ffc6 in -[UIApplication sendEvent:] ()
It seems the system is trying to make the field become first responder, but while it does its thing my dealloc method is reached and the field itself is gone.
Any clue as to what can be done to avoid this ?
It happens when I touch the close button slightly before touching the textField. If I do the opposite, it won't crash.
Thank you
Rafael