Code redundancy ... I have to call viewDidUnload in dealloc

I will not go into what is called when and why. (There is already a lot of things)

Since we cannot rely on viewDidUnloadwhich is called before dealloc, I find myself with a lot of duplicated code between methods.

- (void)viewDidUnload {
      [super viewDidUnload];
      self.foo = nil;
      self.bar = nil;
}

- (void)dealloc {
      [super dealloc];        
      [foo release];
      [bar release];
      [abc release];
}

Backup Code, ick. Does anyone know the problem with this anymore?

- (void)viewDidUnload {
      [super viewDidUnload];
      [foo release];
      foo = nil;
      [bar release];
      bar = nil;
}

- (void)dealloc {
      [super dealloc];
      [self viewDidUnload];
      [abc release];
}

Of course, I have an additional challenge [super viewDidUnload], but I believe that this is not a problem, because it just does things that would be done deallocanyway. I also switched viewDidUnload, so he did not use accessors.

+3
source share
2 answers

deallocs nil -releaseOutlets. ( , , .) . viewDidUnload dealloc, undefined .

+2

, viewDidUnload, , / , viewDidUnload, dealloc.

+5

Source: https://habr.com/ru/post/1788518/


All Articles