Re: When to remove Gesture Recognizers
Re: When to remove Gesture Recognizers
- Subject: Re: When to remove Gesture Recognizers
- From: Quincey Morris <email@hidden>
- Date: Wed, 24 Feb 2016 12:41:14 -0800
- Feedback-id: 167118m:167118agrif8a:167118sK6fmGD2CU:SMTPCORP
On Feb 24, 2016, at 12:17 , Dave <email@hidden> wrote:
>
> I’m adding a Gesture Recognizer to a view in the awakeFromNIB method. This works ok but I’m getting crashes sometimes and I’m wonder it its because I’m not removing it? If so, when is the best place to call RemoveGestureRecognizer?
I add them in viewWillAppear and remove them in viewDidDisappear (of the relevant view controller, of course). I don’t see any point in adding them when the view loads, since they’re only effective when the view is present in the “live” view hierarchy, hence appear/disappear seems appropriate.
I dunno what anyone else thinks, but in may mind the trend is away from doing anything in awakeFromNIB, if for no other reason than you don’t know for sure how many times it will be called. For things that need to be done after NIB loading, viewDidLoad (or windowDidLoad) seems like a better choice.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden