I have an iphone application with multiple views and related controllers and xib files. In the controller for the first view that is loaded I am trying to access the delegate for the application but the object that is returned is nil
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
Any ideas why it would be nil?
Because it is not (yet) set. The UIApplication delegate is usually instantiated and set from the MainWindow nib file. If you access it before the nib is loaded completely (e.g. an init method in a controller in the same nib), it is nil.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With