1
votes

In the Apple sample code, the AppDelegate contains window and navigationController as instance variable. (http://developer.apple.com/library/ios/#samplecode/TableViewSuite/Listings/1_SimpleTableView_Classes_SimpleTableViewAppDelegate_h.html%23//apple_ref/doc/uid/DTS40007318-1_SimpleTableView_Classes_SimpleTableViewAppDelegate_h-DontLinkElementID_5)

@interface SimpleTableViewAppDelegate : NSObject <UIApplicationDelegate> {

    UIWindow *window;
    UINavigationController *navigationController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UINavigationController *navigationController;

The code generated by XCode4 is only as simple as

@interface SimpleTableViewAppDelegate : NSObject <UIApplicationDelegate> {
}
  1. Why the two instances variables can be missed?
  2. Why only the *window need to be declared as IBOutlet, but not *navigationController?

Thanks.

1

1 Answers

0
votes

The LLVM compiler used by Xcode 4 can automatically generate instance variables for synthesized properties. When a property is declared and synthesized, the compiler will automatically generate the corresponding ivar. It's a great feature as it not only saves typing but also makes the external interface of a class cleaner.