Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access app delegate fields within other classes?

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?

like image 731
UpCat Avatar asked Nov 29 '22 16:11

UpCat


1 Answers

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];
like image 90
senthilM Avatar answered Dec 21 '22 05:12

senthilM