我可以在另一个应用程序中正常工作,完全相同的代码,并且所有内容都在情节提要中链接?我不知道发生了什么。似乎 assignmentInfo.className 字符串保持为空。并且描述方法也是nul。看一看:
AddEditViewController.h -
{
IBOutlet UIDatePicker *dateTimePicker;
}
@property (nonatomic, strong) IBOutlet UITextField *className;
@property (nonatomic, strong) IBOutlet UITextField *assignmentTitle;
@property (nonatomic, strong) IBOutlet UITextField *assignmentDescription;
@property (nonatomic, strong) IBOutlet UISwitch *procrastinationNotificationSwitch;
@property (nonatomic,strong)AssignmentInfo *assignmentInfo;
- (IBAction)addTheInfo:(id)sender;
AddEditViewController.m -
{
if (!_assignmentInfo) {
_assignmentInfo = [[AssignmentInfo alloc]init];
}
return _assignmentInfo;
}
- (IBAction)addTheInfo:(id)sender {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
dateFormatter.timeZone = [NSTimeZone defaultTimeZone];
dateFormatter.timeStyle = NSDateFormatterShortStyle;
dateFormatter.dateStyle = NSDateFormatterShortStyle;
NSString *dateTimeString = [dateFormatter stringFromDate: dateTimePicker.date];
self.assignmentInfo.className = self.className.text;
self.assignmentInfo.assignmentTitle = self.assignmentTitle.text;
self.assignmentInfo.assignmentDescription = self.assignmentDescription.text;
self.assignmentInfo.dateTimeString = dateTimeString;
NSLog(@"%@",self.assignmentInfo.className);
NSLog(@"%@",self.assignmentInfo.description);
[self presentMessage:self.assignmentInfo.description];
}
分配信息.h -
@property (nonatomic,strong)NSString *className;
@property (nonatomic,strong)NSString *assignmentDescription;
@property (nonatomic,strong)NSString *assignmentTitle;
@property (nonatomic,strong)NSString *dateTimeString;
@property (nonatomic)bool notifcationStatus;
分配信息.m -
-(NSString *)description
{
return [NSString stringWithFormat:@"Class: %@\r Assignment Title: %@ \rAssignment Description: %@ \rDue: %@ \r%s", self.className, self.assignmentTitle, self.assignmentDescription, self.dateTimeString,self.notifcationStatus ? "Notification On" : "Notification Off"];
}