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

  • Home
  • SEARCH
  • 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 6779043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:20:17+00:00 2026-05-26T16:20:17+00:00

I have an tableview which is loaded from a mutablearray as listed below. However

  • 0

I have an tableview which is loaded from a mutablearray as listed below. However I need to asign each item in the array an ID and have a tickbox next to the item. Basically it’s preferences for our search, it lets users prioritise by whichever tickboxes are ticked. So I’ll want to save which items are ticked to a plist or similar.

Heres how the array is loaded:

arryTableIconsText =     [[NSMutableArray alloc] init]; 

[arryTableIconsText addObject:@"Facilities for partially sighted or blind people"];
[arryTableIconsText addObject:@"An 'assistance dogs welcome' policy"];
[arryTableIconsText addObject:@"Disabled access facilities for wheelchair users (with assistance)"];
*more items added here*

arryTableIcons = [[NSMutableArray alloc] init];

[arryTableIcons addObject:@"visuallyImpaired_off.png"];
[arryTableIcons addObject:@"guidedogs_off.png"];
[arryTableIcons addObject:@"wheelchairassist_off.png"];
    *more items added here*

And then loaded in to a table like so:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }

    cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
    cell.textLabel.numberOfLines = 0;
    cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0];

    cell.textLabel.text = [arryTableIconsText objectAtIndex:indexPath.row];
    cell.imageView.image = [UIImage imageNamed:[arryTableIcons objectAtIndex:indexPath.row]];   

    return cell;
}

The result is the following:

Icons

But I don’t know where to go from here to convert it in to a checkbox to the right of each cell with the ID saved?

Any tips really will be appreciated, Tom

  • 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-26T16:20:17+00:00Added an answer on May 26, 2026 at 4:20 pm

    Use an NSMutableIndexSet instance variable and populate it with the index of the cells being checked.

    Then in the cellForRowAtIndexPath method, set the accessory type of the cell to UITableViewCellAccessoryTypeCheckmark or UITableViewCellAccessoryTypeNone depending on whereas the indexPath.row is in the NSMutableIndexSet or not.

    Finally, when the cell is tapped, add the indexPath.row to the indexset if not alread, or remove it if it already was present, to toggle the status of the corresponding cell, then call reloadData on the tableView.

    I see in your code too that you are not familiar with the reuse mechanism of UITableViewCells. You should read the “Table View Programming Guide” in Apple’s documentation and learn how to implement cellForRowAtIndexPath in a more efficient and reactive way (in term of reactivity and memory footprint)


    Example

    // Let selectedCellIndexes be an instance variable in your .h of type NSMutableIndexSet*
    // Initialize it (probably at the same place you initialise your texts & icons, once for all, probably in your init method
    selectedCellIndexes = [[NSMutableIndexSet alloc] init];
    

    Then to fill the cells:

    -(UITableViewCell*)tableView:(UITableView*)tv cellForRowAtIndexPath:(NSIndexPath*)indexPath {
      // Try to recycle and already allocated cell (but not used anymore so we can reuse it)
      UITableViewCell* cell = [tv dequeueCellWithReuseIdentifier:...];
      if (cell == nil) {
        // If we didn't manage to get a reusable (existing) cell to recycle it
        // then allocate a new one and configure its general properties common to all cells
        cell = [[[UITableViewCell alloc] initWithStyle:... reuseIdentifier:...] autorelease];
    
        // ... configure stuff that are common to all your cells : lineBreakMode, numberOfLines, font... once for all
        cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
        cell.textLabel.numberOfLines = 0;
        cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0];
      }
    
      // Then here change the stuff that are different between each cell
      // (this code will be executed if the cell has just been allocated as well as if the cell is an old cell being recycled)
      cell.textLabel.text = [arryTableIconsText objectAtIndex:indexPath.row];
      cell.imageView.image = [UIImage imageNamed:[arryTableIcons objectAtIndex:indexPath.row]];
      cell.accessoryType = [selectedCellIndexes containsIndex:indexPath.row] ? UITableViewCellAccessoryTypeCheckmark : UITableViewCellAccessoryTypeNone;
    
      return cell;
    }
    

    And finally, to toggle the checkmarks:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
      if ([selectedCellIndexes containsIndex:indexPath.row]) {
        [selectedCellIndexes removeIndex:indexPath.row];
      } else {
        [selectedCellIndexes addIndex:indexPath.row];
      }
      [tableView reloadData];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, I have a tableView which is loaded from the following array called exerciseArray
I have a tableview with each cell loaded from a xib. It is in
I have an app which contains a scrollview with several tableviews. Each tableview is
I have a tableview which displays an image that is obtained from a server
I have a tableView which has cells with phone numbers. The app is not
I have a view which I built in Interface builder with a tableview and
I have a simple table view which is editable. All I need the user
I have around 20 tableview cells that each contain a number (2-5) thumbnail sized
I have a UITableView in my app in which I load several images from
I have tableview which holds a list of data, when users press Edit i

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.