iphone - Best Application Delegate Practice -


I'm making some apps here and there, and I know my way, is it always confused with me that they , And where is the best place to set them up, I have some questions about how to reach things and how they have reached them.

Do you want to include your application delegation header file in any other file that you want to access it? Say that I have a visual controller, which I would like to use, inside me in my view controller. H need to be included. H? Or I can set it up:

  @ Class AppDelegate;  

Can you access only by delegating by typing out:

  [UIApplication sharedApplication]. Delegate  

each and every time? Is there something that I just have to use? Or I can determine the following in each of my implementations. H:

  AppDelegate * Representative; Inside the   

and init function, enter the singleton instance in that variable?

Sorry if this structure was locked, but I think it is a logical question that people have to face a problem and solve.

Maybe you need to reconsider how you're using App Rep? It seems to me as if you are not designing a very good class.

However, there is a way to make it easy. Do not put it in init when you need it, then use it.

  MyAppDelegate * delegate = (MyAppDelegate *) [[UIApplication sharedApplication] delegate];  

Naturally, replace MyAppDelegate with the name of the actual class of your app representative.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -