我正在使用Xcode 4.4.1.当我在.m文件中定义 @property like UINavigationController或NSArrayin .h文件时,我必须@synthesize在.m文件中.但有些人@property喜欢UITabBarController或者NSString我没有这样做才能@synthesize让它发挥作用.
我的问题是@property需要@synthesize什么,什么不需要.
AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
UITabBarController *_tabBar;
UINavigationController *_navBar;
}
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, retain) Employee *empView;
@property (nonatomic, retain) UITabBarController *_tabBar;
@property (nonatomic, retain) UINavigationController *_navBar;
Run Code Online (Sandbox Code Playgroud)
AppDelegate.m
@implementation AppDelegate
@synthesize _navBar;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after …Run Code Online (Sandbox Code Playgroud)