I am trying to do reminder app for iOS7 but my data from UITextField and UIDatePicker wont display on my UITableViewCell.
The table cell is blank (sorry for my bad english)
This is my AddToDoViewController.m which has the UITextField and UIDatePicker
- (IBAction)save:(id)sender {
[self.itemText resignFirstResponder];
//Get the Current date
NSDate *pickerDate = [self.datePicker date];
//Scheule the notification
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = pickerDate;
localNotification.alertBody = self.itemText.text;
localNotification.alertAction = @"Show the To Do List";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
//Requested to reload table view data
[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadData" object:self];
//Dismiss the view controller
[self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)cancel:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
This is my ToDoViewController.m which is the tableView that gets data from the AddToDoViewController and displays it:
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reloadTable)
name:@"reloadData"
object:nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[[UIApplication sharedApplication] scheduledLocalNotifications] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
//Get list of local notification
NSArray *localNotifications = [[UIApplication sharedApplication] scheduledLocalNotifications];
UILocalNotification *localNotification = [localNotifications objectAtIndex:indexPath.row];
//Display notification info
[cell.textLabel setText:localNotification.alertBody];
[cell.detailTextLabel setText:[localNotification.fireDate description]];
return cell;
}
- (void)reloadTable {
[self.tableView reloadData];
}