我有一个 Uitableview,它的附件类型设置为“CheckMark”,如果选择了单元格(选中)我想将单元格的内容添加到数组中,如果未选中,我想从数组中删除相同的内容。
我已将此代码添加到tableView:didSelectRowAtIndexPath:
:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
NSIndexPath *tableSelection = [listingSet indexPathForSelectedRow];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
cell.accessoryType = UITableViewCellAccessoryNone;
[listingSet deselectRowAtIndexPath:tableSelection animated:YES];
}
else {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
ID = [NSString stringWithFormat:@"%@",[[ParsedData valueForKey:@"ID"]objectAtIndex:indexPath.row]];
NSLog(@"++++++IDSSS %@",ID);
NSString *titlename = [NSString stringWithFormat:@"%@.%@",[[ParsedData valueForKey:@"UserFileName"]objectAtIndex:indexPath.row],[[ParsedData valueForKey:@"fileExtension"]objectAtIndex:indexPath.row]];
[Selectedfiles addObject:ID];
[Selectedfiles retain];
NSLog(@"++++++Titlesss %@",Selectedfiles);
[listingSet deselectRowAtIndexPath:tableSelection animated:YES];
}
}