views:

44

answers:

1

Hey, each todo app has a empty box on the left handside, when you touch the box, it changes to a checked box. When you tap it again, the checkmark disappears. I think everybody knows what I mean.

As you see it here (right):

alt text

How would I realize something like that ? Is it a UIButton ? I'm working with Core Data, how would I save the state ? With a boolean varibale ?

I tried to solve my problem now for days, but wasn't able to get it work.

Would be soo nice, when you could help me. Thx a lot ! Sebastian

A: 

You can use a UIButton with different images for the default and selected states. Then, if you set the selected property to YES, the selected image will show instead.

To store it, I'd say that a BOOL should be enough.

pgb
Thank you very much. How does it work with the cellForRowAtIndexPath ? And how do I work with the Button for the row it is in. A bit of Code would be very helpful.I now made it this way: if (self.selectedButton.selected == YES) { [selectedButton setSelected:NO]; } else { [selectedButton setSelected:YES]; }But how do I connect that to the row in the tableview ? I hope you can understand what I mean :| thx a lot !!
Sebastian
You should either use a cell subclass, where you can add the `UIButton`, or add a tag to the `UIButton`, so you can search for it in the view hierarchy.Small inline tip: you may want to do `self.selectedButton.selected = !self.selectedButton.selected`
pgb