ODRefreshControl icon indicating copy to clipboard operation
ODRefreshControl copied to clipboard

Question about dealloc

Open gfxcc opened this issue 10 years ago • 0 comments

why you implement dealloc like this?

  • (void)dealloc { [self.scrollView removeObserver:self forKeyPath:@"contentOffset"]; [self.scrollView removeObserver:self forKeyPath:@"contentInset"]; self.scrollView = nil; }
  • (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; if (!newSuperview) { [self.scrollView removeObserver:self forKeyPath:@"contentOffset"]; [self.scrollView removeObserver:self forKeyPath:@"contentInset"]; self.scrollView = nil; } }

why not just removeObserver in (void)willMoveToSuperview like this:

  • (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; [self.scrollView removeObserver:self forKeyPath:@"contentOffset"]; [self.scrollView removeObserver:self forKeyPath:@"contentInset"]; self.scrollView = nil; }

Another question, when the function dealloc will be called?

Thanks

gfxcc avatar Dec 28 '15 07:12 gfxcc