Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to release a gesture recognizer?

Tags:

If I add a gesture recognizer to a table cell called cell, e.g.:

UILongPressGestureRecognizer *_longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(cellGestureRecognized:)]; _longPressRecognizer.allowableMovement = 20; _longPressRecognizer.minimumPressDuration = 1.0f; [cell addGestureRecognizer:_longPressRecognizer]; [_longPressRecognizer release], _longPressRecognizer = nil;  

Do I need to manually call -removeGestureRecognizer: on this cell at some point, or does the gesture recognizer get removed and released for me when the cell is no longer used?

like image 743
Alex Reynolds Avatar asked Jul 18 '10 08:07

Alex Reynolds


1 Answers

The gesture recognizers are added to an internal NSMutableArray of the view. This array will be released once the view is deallocated. Thus -removeGestureRecognizer: doesn't need to be called manually.

like image 132
kennytm Avatar answered Oct 21 '22 12:10

kennytm