通常情况下,当我们有一个界面元素链接到一个类的字段,我们使用关键字“IBOutlet中”通知预copiler:使用访问器对IB元素实例有什么优势?
@interface MyController : NSObject {
IBOutlet NSWindow *theWindow;
}
,并在执行我们直接指针theWindow
使用调用NSWindow类的方法!
但是,告诉预编译器创建一些访问器以访问由“theWindow”指向的对象并通过访问器管理对象有什么优势?
实施例:
@interface MyController : NSObject {
NSWindow *theWindow;
}
@property(retain) IBOutlet NSWindow *theWindow;
@implementation MyController
@synthesize theWindow;
@end
是否使用第二溶液的(对于所有指针接口的元素)减慢了应用程序的性能?
什么时候使用第二种方法而不是第一种方法是一种好的做法?
谢谢!