Apple recomments that you not call setters in the init and especially dealloc routines.
This is due to the fact that the object is only partially set up at this time, and setters could have observers attached to them, or could be overridden by subclasses, and otherwise have undesirable affects during dealloc, or could be confused during init with a partially configured object.
Hence, you normally use:
_navigationController = [[NavController alloc] init];
style code in your init routine,
[_navigationController release];
style code in your dealloc, and setters in other code where the object is known to be fully complete.
Some cases to consider:
- Subclass overrides setNavigationController and references its own ivars allocated by init. Crash on init.
- Subclass overrides setNavigationController and references its own ivars released in dealloc. Crash on dealloc.
- Subclass overrides setNavigationController and redraws some parts of the screen. Pointless waste of cycles, or glitchy display.
- Other objects being deallocated at the same time observe navigationController and those observers fire during dealloc
- etc