I have a gesture recognizer pulled from storyboard and it is working fine and dandy…
EXCEPT when I simulate a low memory warning. At that point, it crashes with the error:
[UISwipeGestureRecognizer retain]: message sent to deallocated instance 0x8627330
To get it to not crash, what I have to do is set the gesture recognizer as a strong property and comment out the autogenerated set to nil in viewdidload:
//[self setSwipeGestureRecognizer:nil];
I got to this solution randomly, and Im hoping someone can explain what is going on here?
Fascinating. When you first posted this I was assuming that there was some problem with your code, but given your clarifying comments, I decided to try it out myself. I experience the same behavior you do.
Specifically, I create a gesture recognizer in Interface Builder and linked it to an appropriate
IBActionand confirmed it worked fine, even if I push to and pop from another view controller. But if I simulate a memory warning when at that secondary view controller, immediately upon return to the original view controller, I receive the same crash you do.It’s easily remedied. Looks like you have an approach, or you can simply bypass Interface Builder entirely, and create your own gesture recognizer in code, and you won’t have this problem, e.g.,
If you create it manually like this, you don’t get the crash upon returning back to the view after simulating a memory warning. So that’s your solve.
Fortunately, it looks like this has been remedied in the beta of the next version of Xcode and iOS.