本文介绍了IBOutlet声明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到下面的代码写了3种不同的方式(关于IBOutlet)是否重要,我想说,添加IBOutlet到声明和@property更简洁。

I have seen the code below written 3 different ways (with regards to IBOutlet) Does it matter, I would say adding IBOutlet to both the declaration and the @property was more concise.

JUST属性:

@class SwitchViewController;

@interface iPhone_switcherAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    SwitchViewController *switchViewController;
}

@property(nonatomic, retain) IBOutlet UIWindow *window;
@property(nonatomic, retain) IBOutlet SwitchViewController *switchViewController;
@end

JUST DECLARATION:

JUST DECLARATION:

@class SwitchViewController;

@interface iPhone_switcherAppDelegate : NSObject <UIApplicationDelegate> {
    IBOutlet UIWindow *window;
    IBOutlet SwitchViewController *switchViewController;
}

@property(nonatomic, retain) UIWindow *window;
@property(nonatomic, retain) SwitchViewController *switchViewController;
@end

BOTH:

@class SwitchViewController;

@interface iPhone_switcherAppDelegate : NSObject <UIApplicationDelegate> {
    IBOutlet UIWindow *window;
    IBOutlet SwitchViewController *switchViewController;
}

@property(nonatomic, retain) IBOutlet UIWindow *window;
@property(nonatomic, retain) IBOutlet SwitchViewController *switchViewController;
@end

cheers gary

cheers gary

推荐答案

不要紧。使用10.6 64位SDK,你也可以写没有ivar的属性:

Should not matter. With the 10.6 64-bit SDK you can also write the property without the ivar:

@class SwitchViewController;

@interface iPhone_switcherAppDelegate : NSObject <UIApplicationDelegate> {
}

@property(nonatomic, retain) IBOutlet UIWindow *window;
@property(nonatomic, retain) IBOutlet SwitchViewController *switchViewController;
@end

这篇关于IBOutlet声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 05:22