I am doing an app as a starter to get some experience, I am making a simple app that stores assignments in a table view. So I have a table view as a main view and a plus button that pulls up a modal view controller that allows the user to enter information about the - class name, assignment title, assignment description, due date, and a switch to turn on/off notifications. These values are stored in a AssignmentInfo model. I need to be able to archive (NSCoding) these values, and add to them when new data is entered. Here is some sample code that might help give a better idea:
AssignmentInfo.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;
AddEditViewController.m -
{
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;
AddEditViewController.m -
- (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);
[self dismissViewControllerAnimated:YES completion:nil];
}