title: How to preserve the index path value in the table view in iPhone?
body: <p>I have created a table view and displayed the datas. When i click the data in the table view, i put the accessory mark (using UITableViewCellAccessoryCheckmark, Like, Check Mark). Now i want to preserve the state of index position. Because when i go to the another class and then come back to the  table view, the previous state(accessory mark) will be displayed. SO how can i preserve the state, which means store or save the indexpath value.(Without using AppDelegate method)so How can i achieve this?   </p>
  
  <p>Here my sample code is,</p>
  
  <pre><code> - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  
   if (newRow != oldRow)
  {
      UITableViewCell *newCell = [tableView cellForRowAtIndexPath:
                                  indexPath];
      newCell.accessoryType = UITableViewCellAccessoryCheckmark;
  
      UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:
                                  checkedData];
      oldCell.accessoryType = UITableViewCellAccessoryNone;
  
      checkedData = indexPath;
  
  }
  if (newRow == oldRow) {
      UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  
      if (cell.accessoryType == UITableViewCellAccessoryNone) {
          cell.accessoryType = UITableViewCellAccessoryCheckmark;
  
      } else {
  
          // cell.accessoryType = UITableViewCellAccessoryNone;
      }
      checkedData = indexPath;
  }
   }
  </code></pre>
  
  <p>When back to the table view class, the previous state should be preserved. so how can i access that?</p>
  
  <pre><code>   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      if(checkedData == indexPath) // Doesn't works
        {
  
      cell.accessoryType = UITableViewCellAccessoryCheckmark;
       }
  </code></pre>
  
  <p>Please help me out.</p>
  
  <p>Thanks</p>