Is there a good overview of initWithNibName
, awakeFromNib
, and viewDidLoad
that lays out the best way to use each of these and describ
viewDidLoad can get called more than once so it is not an appropriate place for most initialization (although in practice it's called just once unless you are meddling) - that is why awakeFromNib is special and very necessary: it only gets called once.
viewDidLoad doesn't exist on UIView - UIView has awakeFromNib for initialization and there are no other sensible options.
For the past six months I have been happily using awakeFromNib with storyboards (a single storyboard for an app) without any trouble at all and it has behaved perfectly with all outlets configured as specified in the documentation. Then today I took some code apart and put in a new view controller and views and none of it is working as I have experienced in the past i.e. all outlets nil in awakeFromNib. My theory is simple - the SDK sucks because it's very easy to do something trivial somewhere in your chain of controllers/views and classes and break everything.
Now I'm off to research this pointless topic, yet again, when all I need is a simple consistent place to do initialization.