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 6357431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:09:50+00:00 2026-05-24T23:09:50+00:00

following code starts with a blank cells and add a checkmark when selected cell

  • 0

following code starts with a blank cells and add a checkmark when selected cell but, once added, if you press again that cell, it is not erased. I am trying to reset it each time that didSelectRowAtIndexPath is called. How to clear cell in order to be marked only one? Thanks.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        cell.accessoryType = UITableViewCellAccessoryNone;

    if (indexPath.section == 0) {

    switch (indexPath.row) {
        case 0:
            labelInfo.text=@"1";
            cell.accessoryType = UITableViewCellAccessoryCheckmark; 
            break;
        case 1:
            labelInfo.text=@"2";
            cell.accessoryType = UITableViewCellAccessoryCheckmark; 
            break;
        case 2:
            labelInfo.text=@"3";
            cell.accessoryType = UITableViewCellAccessoryCheckmark; 
            break;
        case 3:
            labelInfo.text=@"4";
            cell.accessoryType = UITableViewCellAccessoryCheckmark; 
            break;
        case 4:
            labelInfo.text=@"5";
            cell.accessoryType = UITableViewCellAccessoryCheckmark; 
            break;
        default:
            break;
        }
    }
}        
  • 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-05-24T23:09:51+00:00Added an answer on May 24, 2026 at 11:09 pm

    Just copy-paste this. It works.

      //in your .h file
       int selectedCell;
    
       //in your .m file
       - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
       {
    
           NSString* cellIdentifier = @"cellIdentifier";
           UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
           if(cell == nil)
           {
               cell = (UITableViewCell*) [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
    
           }
           cell.accessoryType = UITableViewCellAccessoryNone;
    
           if (indexPath.section == 0) {
    
               if(indexPath.row == selectedCell)
               {
                       cell.accessoryType = UITableViewCellAccessoryCheckmark; 
                       cell.selected = YES;
               }
               else
               {
                   cell.accessoryType = UITableViewCellAccessoryNone;
                   cell.selected = NO;
               }
           }
       }
    
    
    
       - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
       {
           selectedCell = indexPath.row;
           [tableView reloadData];
           //remaining code.
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a line of code that starts like the following: Func1(Func2(Func3 Is
The following piece of code runs fine when parallelized to 4-5 threads, but starts
I have the following code snippet that shows a list of numbers, and highlights
In Android I have the following code to blank an EditText box when clicked.
I have the following code TransitionManager.start(babyPreloader,{type:Fade, direction:Transition.OUT, duration:0.5, easing:Regular.easeOut}); var tempPreloader:DisplayObject = babyPreloader as
If I write the following code: session_start(); $_SESSION['user_id']='daniel'; the variable stays fine as long
The following code: class Log: BAT_STATS = ['AB', 'R', 'H', 'HR'] def __init__(self, type):
The following code causes a NullReferenceException tStartParameter = String.Format(tStartParameter, tTo, tSubject) tProcess = Process.Start(New
I have the following code: //------------------------------------------------------// // When the document is ready, start firing
I have a header.html which start with session_start();. Then the following code, $_SESSION['cart'][$sw_id] is

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.