in one of my controllers I want to access fields of my app delegate. So to retrieve app delegate I use the following code:
[[UIApplication sharedApplication] delegate];
But when I try to cast it to my delegate's name I get the error that the name is undeclared.
Do I have to import the header file of the app delegate in the class where I want to access the fields?
you have to provide header file(MyAppDelegate.h) for app delegate.you can access appdelegate members as following.please see the link
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
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