i’m clicking on a row in a table and going to a new view, in the viewdidload i’m taking the nav.title and putting it in a url to send to a php page. However the url is sending before the nav.title is initialised, so i’m receiving null back from php. How do i make sure the nav.title is initialised before viewdidload, or can someone think of a better way to structure this code? thanks
Share
The
viewDidLoadmethod is inUIViewController. Something I find tricky with view controllers is that sometimes you instantiate them in code, and sometimes you instantiate them from a NIB-file.These two paths of instantiation do not share a common method for proper initialization. So I have taken into practice to alway implement all my
UIViewControllersubclasses using a patter like this:This way I can always trust
primitiveInitto be called on my view controller before they are displayed on screen, and receive any external events.What I have done is actually that I have added a category on
NSObjectthat callsprimitiveInitfrom both the root classinitmethod, and from the root classawakeFromNibmethod. This way I only need to implementprimitiveInitin any of my classes and never care of how they are instantiated. But this is slightly more advanced, explaining how it works is a topic on it’s own.