-1
У меня есть 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];
}
}