Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ljg93

macrumors member
Original poster
Mar 13, 2011
98
0
Hello,

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

Thanks
 
Hello,

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

Thanks

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.
 
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
Code:
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.