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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:08:51+00:00 2026-05-13T15:08:51+00:00

I have a list app where users hit the + button and enter in

  • 0

I have a list app where users hit the + button and enter in an item that they want to appear in the list and hit save. The table is saved with core data. The only problem is when the cell is taped I want a checkmark to be displayed. Ive enabled multiple selection with

UITableViewCell *thisCell = [tableView cellForRowAtIndexPath:indexPath]; 
if (thisCell.accessoryType == UITableViewCellAccessoryNone) {
    thisCell.accessoryType = UITableViewCellAccessoryCheckmark;  
} else {
    thisCell.accessoryType = UITableViewCellAccessoryNone;
} 
[tableView deselectRowAtIndexPath:indexPath animated:NO]; 

I would like the checkmarks to be persisted in the cell after the user exits. I have created an attribute in my entity called “checks” and gave it the type of boolean but I dont know how to make it where if you hit a row then a check appears and is persisted. Any help would be greatly appreciated. Thanks

  • 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-13T15:08:52+00:00Added an answer on May 13, 2026 at 3:08 pm

    This is how I do it. One notable point: CoreData does not store booleans, so any property labeled “boolean” is actually of type NSNumber. You’ve got to remember to convert back and forth when dealing with CoreData and boolean values.

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        NSManagedObject *selectedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
    
    
        if ([[selectedObject valueForKey:@"isDone"] boolValue]) {
            [selectedObject setValue:[NSNumber numberWithBool:NO] forKey:@"isDone"];
        } else {
            [selectedObject setValue:[NSNumber numberWithBool:YES] forKey:@"isDone"];
        }
    }
    

    I have my UITableViewController set as the the delegate for the NSFetchedResultsController, so the changes I made to the managed objects in the query ^^^ will cause the following two methods to be run.

    - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
        [self.tableView reloadData];
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString *defaultCellIdentifier = @"Item";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:defaultCellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:defaultCellIdentifier] autorelease];
        }
    
        NSManagedObject *item = [[self fetchedResultsController] objectAtIndexPath:indexPath];
        cell.textLabel.text = [item valueForKey:@"name"];
    
        if ([[item valueForKey:@"checks"] boolValue]) {
            cell.accessoryType = UITableViewCellAccessoryCheckmark;
        } else {
            cell.accessoryType = UITableViewCellAccessoryNone;
        }
    
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
        return cell;
    }
    

    Here’s how everything ties together

    1. User clicks on a row
    2. tableView:didSelectRow… method changes the “isDone” property of the appropriate managed object.
    3. the fetched results controller notices that a managed object has changed and calls the controllerDidChangeContent method on its delegate.
    4. My controllerDidChangeContent method just reloads all the data in the table view
    5. When the tableView is reloaded, my tableView:cellForRow… method checks the “isDone” property of the managed item to see if the cell should have a checkmark or not.

    And just so you don’t get confused, I initially used a generic NSMangagedObject to store row state, which is why the first method I posted says, [selectedObject valueForKey:@"isDone"]. Later I switched to a subclassed managed object named JKItem, which is why the second set of methods is able to use item.isDone without generating a compiler warning.

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

Sidebar

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.