I have made one sample demo.
Like selected cell print after "Done"button clicked.
It is working fine.

Code is
=======

```
@synthesize arrayContainer,filteredRecipes,myTableView,filtered,selectedRaw;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.arrayContainer = [[NSMutableArray alloc]initWithObjects:@"One",@"Two",@"Three",@"Four",@"Five",@"Six",@"Seven",@"Eight",@"Nine", nil];
    self.selectedRaw = [[NSMutableArray alloc]init];

}

-(IBAction)printSelectedItem:(id)sender
{
    NSLog(@"The Selected Items are %@",self.selectedRaw);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(filtered == YES)
    {
        return self.filteredRecipes.count;

    }
    else
    {
        return self.arrayContainer.count;

    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"myCell";

    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:identifier];

    if(filtered == YES)
    {
        cell.textLabel.text = [self.filteredRecipes objectAtIndex:indexPath.row];

    }
    else
    {
        cell.textLabel.text = [self.arrayContainer objectAtIndex:indexPath.row];

    }

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {

        cell.accessoryType = UITableViewCellAccessoryNone;
        // NSString *string = [self.selectedRaw objectAtIndex:indexPath.row];

        [self.selectedRaw removeObjectAtIndex:indexPath.row];

    } else {

        cell.accessoryType = UITableViewCellAccessoryCheckmark;
        NSString *temp = [self.arrayContainer objectAtIndex:indexPath.row];
        [self.selectedRaw addObject:temp];
    }

}

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{

    [searchBar setShowsCancelButton:YES animated:YES];
}

-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{

    if([searchText length] == 0)
    {
        self.filtered   = NO;
    }
    else
    {
        self.filtered = YES;

        self.filteredRecipes = [[NSArray alloc]init];

        NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@",searchText];

        filteredRecipes = [self.arrayContainer filteredArrayUsingPredicate:resultPredicate];
    }

    [self.myTableView reloadData];
}

```

Question is
===========

-> When I print selected row of table view ,Displayed in log perfectly.

-> But when I deselected those selected item it gives me n error.

Please give me solution.

My another question is when I have searched particular item (selected) it gives me selected item perfectly,then i deselect item after I have canceled searching then it gives me again selected item which I did deselect earlier.

Output image

[![enter image description here](https://i.stack.imgur.com/ES377.png)](https://i.stack.imgur.com/ES377.png)

**selected Raw**

[![enter image description here](https://i.stack.imgur.com/XgJ9o.png)](https://i.stack.imgur.com/XgJ9o.png)

**Unchecked second raw**

[![enter image description here](https://i.stack.imgur.com/P2QVp.png)](https://i.stack.imgur.com/P2QVp.png)

[![enter image description here](https://i.stack.imgur.com/0P3ku.png)](https://i.stack.imgur.com/0P3ku.png)

[![enter image description here](https://i.stack.imgur.com/YvWuo.png)](https://i.stack.imgur.com/YvWuo.png)