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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:31:20+00:00 2026-05-21T21:31:20+00:00

I am working on putting a checkbox in every row of a table view.

  • 0

I am working on putting a checkbox in every row of a table view. When I tap a row, its value should get saved into an array, on tap of another row, its value should likewise get saved to the same array, and on a tap of the same row, the value should get deleted from the array.

Please suggest to me how to implement this one. I was using the following code in didSelectRowAtIndexPath method but I was not able to do it.

if([arrData count]==0)
{
    strlast = [arrName objectAtIndex:indexPath.row];
    [arrData addObject:strlast];
    NSLog(@"string checked in arrData   %@",strlast);
}
else 
{
    for(int i = 0 ;i < [arrData count]; i++) 
    {
        NSLog(@"[arrData count]:%d",[arrData count]);
        strSelected = [arrName objectAtIndex:indexPath.row];
        NSLog(@"strSelected:%@",strSelected);

        for(int i = 0 ;i < [arrData count]; i++) 
        {
            if([strSelected caseInsensitiveCompare:[arrData objectAtIndex:i]])
            {
                [arrData addObject:strSelected];
                NSLog(@"arrData:%@",arrData);
            }
        }
    }
}
  • 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-21T21:31:20+00:00Added an answer on May 21, 2026 at 9:31 pm

    list is the array name which contains all the data that is viewed in tableview replace it with your own array name
    Suppose tableArray is your array in which values are inserted and deleted.
    in .h file

    NSMutableArray *tableArray;
    

    in .m file in view didload

    tableArray=[[NSMutableArray alloc]init];
    

    tableview didselect row method:-

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
    
    if ([tableArray count]>0) {
    
            if ([tableArray containsObject:[list objectAtIndex:indexPath.row]]) {
                [tableArray removeObject:[list objectAtIndex:indexPath.row]];
                NSLog(@"data removed");
                NSLog(@"tableArray%@",tableArray);
            }
            else {
                [tableArray addObject:[list objectAtIndex:indexPath.row]];
                NSLog(@"data added");
                NSLog(@"tableArray%@",tableArray);
            }
    
        }
        else {
            //[tableArray addObject:[NSString stringWithFormat:@"%d",indexPath.row]];
            [tableArray addObject:[list objectAtIndex:indexPath.row]];
            NSLog(@"data added");
            NSLog(@"tableArray%@",tableArray);
        }
    
    
    }
    

    release the array in dealloc
    I have tested the code I hope it might help you….

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

Sidebar

Related Questions

I'm having trouble putting this problem into searchable terms. I'm working on an Android
Working with H2 I get this error when I try to write a row
I working on grouped table view based work in that in that i want
In a project I'm currently working for, we're considering putting system() into php.ini's disable_functions
I was working on encorperating threads into my azure code for putting things on
I'm working on a chat server, and I'm putting the Clients into a Hashtable.
I've managed to get input hooks working, but now I'm kinda lost with putting
i was putting my scripts in my view files (cshtml) when i started working
I'm putting some dates into an array, and would like to have a second
i have a shell script for putting values into an array. The script 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.