saving checked cell on table view

Discussion in 'iOS Programming' started by ljg93, Aug 21, 2011.

  1. ljg93 macrumors member

    Mar 13, 2011

    I am wondering what is the best way to go about saving a checked cell on a table view. I am just creating a simple checklist app and I need the user to check a cell and have it stay checked when the user exits the application until the user again un-checks the cell

  2. ArtOfWarfare macrumors G3


    Nov 26, 2007
    How about a C-array of bools?

    You can store it as a stream of bytes in an NSData in the NSUserDefaults although the exact process for that is a little beyond what I know how to do... I just know I've seen it dome before.
  3. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    Maybe add a state to the objects you are pulling in (unless they are simple strings). But for eg. You have an object, called "Example", and it has the NSString *title, I guess you are showing this title in the UITableView.
    Add another property to the "Example" object, called, clicked. (just a bool, or w/e).
    Then whenever you click the row, change the property of the document (with objectAtIndex:indexPath.row or something similair. Then, whenever you quit or press save. Or next time you actually reload the view, check based upon that property what to show in the cell. like
    Example *example = [exampleArray objectAtIndex:indexPath.row];
    if ([example.isClicked isEqualToString:"clicked"]
      cell.somePropertyForCheckmark = TRUE;
    Ofcourse code isn't correct, i'm not on my Mac, so I've written the code from the head, so THINK about it, before you copy/pasta

    Gz. noxx

Share This Page