erica / iphone-3.0-cookbook-

Sample Code
912 stars 305 forks source link

AppDelegate Interface is Empty #12

Closed acani closed 12 years ago

acani commented 14 years ago

I noticed in a lot of your recipes, @interface HellowWorldAppDelegate is empty. I know you say you do that to keep the code in one file, to make it easier to present for learning purposes, etc. But the problem is, I don't know what the good practices are for the @interface AppDelegate and declaring variables in header files, when to do so, etc...

When selecting the iphone view template, it declares the window and viewController in the AppDelegate interface. It also does:

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet AppNameViewController *viewController;

and in the implementation file it does @synthesize and defines a dealloc method. Even though you say dealloc is never called, what if iPhone one-day decides to start calling it? For convenience, it makes sense to leave it out, but in practice, is it good practice to leave it in?

If we should declare things in the appDelegate, what should be declared? Just the window and viewControllers? which viewControllers? I see some applications on github that define other variables too. But then, sometimes they just define the variables in the implementation w/o declaring them in the header file? When should we do which?

Maybe you could provide one sophisticated, complete project in the beginning with different files, etc. that shows the best practices for organizing an application and defining variables, etc.

Thanks!

Matt