我正在尝试应用一个基本的继承概念,我需要textfield.text
在子视图控制器中显示父 viewcontorller 的。但我得到空值
父母.h
@interface EditEventViewController : UITableViewController
{
UITextField *textEventName;
UITextField *textEventLocation;
UITextField *textStartTime;
UITextField *textEndTime;
UITextField *textDate;
UITextField *textEndDate;
//tried IBOutlet version such as
//IBOutlet UITextField *textEventName;//this didnt work too
}
@property (nonatomic, strong) IBOutlet UITextField *textEventName;
@property (nonatomic, strong) IBOutlet UITextField *textEventLocation;
@property (nonatomic, strong) IBOutlet UITextField *textStartTime;
@property (nonatomic, strong) IBOutlet UITextField *textEndTime;
@property (nonatomic, strong) IBOutlet UITextField *textDate;
@property (nonatomic, strong) IBOutlet UITextField *textEndDate;
父母.m
@synthesize textEndDate=_textEndDate;
@synthesize textDate=_textDate;
@synthesize textEndTime=_textEndTime;
@synthesize textEventName=_textEventName;
@synthesize textStartTime=_textStartTime;
@synthesize textEventLocation=_textEventLocation;
//test inherritance here
DeleteFromCalendar *deleteControl=[[DeleteFromCalendar alloc] init];
NSLog(@"Delete Request for text name %@",self.textEventName.text);
[deleteControl displayParentStrings];
孩子.h
#import "EditEventViewController.h"
@interface DeleteFromCalendar : EditEventViewController
-(void)displayParentStrings;
@end
孩子.m
-(void)displayParentStrings
{
NSLog(@"Display Parent Strings");
NSLog(@"DeleteFromCalendar Event Name %@",textEventName.text);
NSLog(@"DeleteFromCalendar Event %@",textEventLocation.text);
}
NSLOG:
Delete Request for text name Aeronautical Knowledge Review
DeleteFromCalendar Event Name (null)
DeleteFromCalendar Event Lcoation (null)
为什么我会得到空值?