セルをクリックしてオブジェクトを編集した後、セルは他の VC を開いて編集を許可しますが、ユーザーがクリックしてキャンセルすると、セルが選択されたままになり、問題が発生してすぐにクラッシュします。
セル編集:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"addAssignment"])
{
AddEditViewController *addEditController = segue.destinationViewController;
[addEditController setOtherdelegate:self];
}
if ([segue.identifier isEqualToString:@"edit"]) {
UITableViewCell *cell = sender;
AddEditViewController *addEditController = segue.destinationViewController;
[addEditController setOtherdelegate:self];
addEditController.edit = YES;
AssignmentInfo *a = [self.alist objectAtIndex:[self.tableView indexPathForCell:cell].row];
addEditController.assignmentEditing = a;
[self.alist removeObject:a];
[self.tableView reloadData];
NSString *filePath = [self dataFilePath];
[NSKeyedArchiver archiveRootObject:self.alist toFile:filePath];
}
}
キャンセルボタンが押されました:
- (IBAction)addAssignmentCancelButtonPressed:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
必要に応じてプロジェクト全体: http://abdelelrafa.com/AssignmentAppTwo.zip