So it seems like I should be setting my member variables in viewDidLoad
- but I am confused as to why setting these variables in initWithCoder
fails, since both are called at the start of the program.
In particular I have a line of code:
[worldView setMapType:MKMapTypeSatellite];
In which worldView
is a IBOutlet
MKMapView
object. It works under viewDidLoad
, but not initWithCoder
.
The objects do not yet exist when
initWithCoder
is called, and they do whenviewDidLoad
is called. Check yourinitWithCoder
method by logging out the value ofworldView
using something like:and it will be
nil
. They will be initialized before the call toviewDidLoad
, so you can set a property of thatIBOutlet
there.