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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:57:55+00:00 2026-05-24T16:57:55+00:00

Im my table view, I want to switch the accessory from a checkmark, to

  • 0

Im my table view, I want to switch the accessory from a checkmark, to not having a checkmark (and back again) – I currently do it like this:

if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
    cell.accessoryType = UITableViewCellAccessoryNone;
}
else {
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
}

Now I know there is a better way of writing this, any suggestions?

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

    The only problem I see with what you’ve got now is that it relies on the cell to save state. The decision about whether to give a cell a check or not should probably be based not on the cell but on the data that’s being displayed in the cell, like:

    if (vehicle.selected) {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    else {
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    

    If you want to make that a little more cryptic, you could:

    cell.accessoryType = vehicle.selected ? UITableViewCellAccessoryCheckmark
                                          : UITableViewCellAccessoryNone;
    

    Some folks like that notation, others hate it. Check your local coding standards document to find out whether such code is acceptable before using.

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

Sidebar

Related Questions

On each cell of my table view I want to have a bar that
I want to modify my table view cell apparence when the delete button came
In my code, I want to view all data from a CSV in table
this is a noob question.i subclassed my table view cell in interface builder and
I want to draw line in table view cell so that I can place
From coded detailView of my app which has a grouped table view. I want
I want to iterate through a table/view and then kick off some process (e.g.
I want to make a table view in my iPhone Application.. In that table
I want to reload the data within a table view that is contained on
I have a Table View Controller with cells. I want to update the text

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.