Home > Software design >  Should I stop indicator animation right before dismissing view?
Should I stop indicator animation right before dismissing view?

Time:05-27

I know it doesn't really matter in terms of resources but In terms of good practice, I have an activity indicator that starts animating somewhere, and when the task is finished, I dismiss the view that contains that activity indicator. So, because the view is being deallocated it seems redundant to actually tell the activity indicator to stop animating.

So is this code redundant? :

  activityIndicator.stopAnimating() // should this be deleted?
  viewController.dismiss(animated: true)

CodePudding user response:

When you call dismiss function, it dismisses the view controller that was presented modally by the view controller: which removes the VC from memory stack and deallocate all the memory of VC and it's elements. So you can remove the activityIndicator.stopAnimating() line.

  • Related