At your if (pathIndex == indexPath) you're comparing pointers not the values of them, try pathIndex isEqual:indexPath or use (NSComparisonResult)compare:(NSIndexPath *)otherObject Next you're assigning a value to pathIndex without retaining or copying it like pathIndex = indexPath copy (of course now since you're retaining the value, before copying your new object you have to release the previous one pathIndex release;) Finally, no multiple selection is provided by your implementation, only single selection. You could try adding and removing NSIndexPath objects to an NSMutableArray and check against their presence in your mutable array at cellForRowAtIndexPath instead.
At your if (pathIndex == indexPath) you're comparing pointers not the values of them, try pathIndex isEqual:indexPath or use - (NSComparisonResult)compare:(NSIndexPath *)otherObject; Next you're assigning a value to pathIndex without retaining or copying it like pathIndex = indexPath copy; (of course now since you're retaining the value, before copying your new object you have to release the previous one pathIndex release;) Finally, no multiple selection is provided by your implementation, only single selection. You could try adding and removing NSIndexPath objects to an NSMutableArray and check against their presence in your mutable array at cellForRowAtIndexPath instead.
The issue is that you only do something with the accessory if the current row matches pathIndex.... so what if it is a normal cell...? You never set it back. You want... cell. AccessoryType = UITableViewCellAccessoryNone; if (pathIndex isEqual:indexPath) { cell.
AccessoryType = UITableViewCellAccessoryCheckmark; } It is good practice to reset the cells before you set any specific properties.
Create the unique Cell identifier string , Instead of using same for all the cell . Use below code : NSString *RootViewControllerCell = NSString stringWithFormat:@"RootViewControllerCell_%d_%d",indexPath. Row,indexPath.
Section; UITableViewCell *cell = tableView dequeueReusableCellWithIdentifier:RootViewControllerCell.
This completely negates the whole purpose of cell identifiers. Not a good plan! – Simon Lee Jun 14 at 7:55 @Simon Lee :no offense,read the documentation carefully and also let me know for what whole purpose you are talking?
– Jhaliya Jun 14 at 8:02 Regardless of what you may think, using a unique cell identifier for EVERY cell is COMPLETELY wrong. If the cell IS different in layout etc then you have a specific identifier for it, in this case they are the same. I think you should revisit your knowledge of UITableViews – Simon Lee Jun 14 at 8:04 The point of cell identifiers is so that a UITableView can re-use cells of the same layout and style to make performance better, so using a unique identifier for every cell when those cells are the same aside from the actual content is wrong.
– Simon Lee Jun 14 at 8:05 1 Look at Tim Keatings answer. One comment states "Don't think of it as a unique identifier -- think of it more like a type name". I am inclined to agree with Simon.
– Oriacle Jun 14 at 8:43.
I have a tableview, I need to have a checkmark displayed everytime I select a row. (Multiple selection) My code is given below. I am also able to unselect a row.
But I have a problem with the cells being reused. When I select a cell another cell elsewhere also gets selected. Only the checkmark (or no checkmark) is getting reused other details like the row title, etc., don't get reused.
Any solutions to fix this. Thanks in advance.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.