0
任何人都可以在这里请告诉我,下面是从基类继承类的正确方法。如何在Objective-C中正确访问基类属性?
谢谢。
// BaseController.h
@interface BaseController: UIViewController
{
IBOutlet UITextField* m_pNameTxtFld;
}
@property (nonatomic, retain) IBOutlet UITextField* m_pNameTxtFld;
// BaseController.m
-(void) viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
if (self.m_pNameTxtFld)
{
self.m_pNameTxtFld = nil;
}
}
// NewContorller.h
@interface NewContorller: BaseController
{
}
// NewContorller.m
@implementation NewContorller
- (无效)viewDidLoad中
{
self.m_pNameTxtFld.text = @"Test";
}
我们在这里听到了C++口音的痕迹吗? :-)你的“基类”也被称为“超类”,而实例变量不是“成员”,所以你不会看到“m_”命名约定。就像单挑一样。 – Monolo 2013-05-11 10:08:11
谢谢Monolo ...会对它进行检查... :-) – newdev1 2013-05-11 23:53:26