Reputation: 279
Can anyone here please tell me if the below is the right way to inherit a class from the base class.
Thanks.
// 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
- (void)viewDidLoad
{
self.m_pNameTxtFld.text = @"Test";
}
Upvotes: 0
Views: 1396
Reputation: 896
Yes it is the right way. Just remember that you should call [super viewDidLoad] at the beggining of viewDidLoad implementation in subclass.
- (void)viewDidLoad {
[super viewDidLoad];
self.m_pNameTxtFld.text = @"Test";
}
Upvotes: 1