Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8907217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:51:23+00:00 2026-06-15T02:51:23+00:00

I have a tableView who’s datasource is an array with 400 static items in

  • 0

I have a tableView who’s datasource is an array with 400 static items in it. In my app you can select a row and it will place a checkmark on that row. I’m keeping track of the checked item’s indexPaths in another array so that the table can be reloaded later and those items will still be checked.

Since my table has a lot of values in it I’ve added a searchDisplayController. Start typing what your looking for and it’ll filter the list down to those items. You can select rows in the searchResultsTableView and it will check them, just like in the main table with the 400 static rows. However, there’s a problem:

Let’s say you enter a search and narrow the list of 400 items down to the one you’re looking for and you select (checkmark) it. In the full list of 400 items, the one you just searched for might be number 112 in the list, however when you did your search and filtered down to only that one item, instead of adding the indexPath of item 112 to my array that keeps track, it entered the indexPath of item 0 because it was the only item showing in the filtered list.
So when you cancel out of search and go back to the main list instead of their being a checkmark on item 112, there’s a checkmark on item 0.

So I’m looking for a way to keep my filtered array in sync with my main tableView datasource.

The relevant bit of my didSelectRowAtIndexPath method:

if (tableView == self.searchDisplayController.searchResultsTableView) {
    cell.textLabel.text = [filteredattributesArray objectAtIndex:[indexPath row]];
    if(cell.accessoryType == UITableViewCellAccessoryNone){ 
        cell.accessoryType = UITableViewCellAccessoryCheckmark;

        [selectedItemRows addObject:indexPath]; //Add the index path of checked cell into     array to keep track            

        [tableView reloadData];

    } else {
        if(cell.accessoryType == UITableViewCellAccessoryCheckmark) {
            cell.accessoryType = UITableViewCellAccessoryNone;

            [selectedItemRows removeObject:indexPath]; //Remove that index path of unchecked cell from index array

            [tableView reloadData];
        }
    }
    [tableView deselectRowAtIndexPath:indexPath animated:YES];        }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:51:25+00:00Added an answer on June 15, 2026 at 2:51 am

    Don’t use indexPath. Set the tag value on each item in your data array and then keep a list of tags for your “checkedArray”. That way you can evaluate the checked items independent of the cells or tableView structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a tableview controller, when i select a row its pushing another view
I have TableView. My datasource is SQLite database. I'm trying to count a number
I have a tableview and an array source. When I init array in viewDidLoad
I have a TableView who display the name of some Categories by executing this
I have tableview with some names on each cell , how can i get
I have a tableView with a list of items. When a selection is made,
I have a UITable, and class who is it's datasource and delegate. The class
I have tableview, where create new rows and set them layout manually. In every
I have a tableView with a few sections and I have it set for
I have a tableView that present a list of Books, each of the table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.