获取UITableView的取消选择的indexPath数组

Mir*_*lav 2 iphone objective-c ios

通过调用很容易获得一系列选定的UITableView对象行

[tableView indexPathsForSelectedRows];
Run Code Online (Sandbox Code Playgroud)

有没有办法得到我的tableView 取消选择行的反转数组?

Gav*_*vin 5

NSMutableArray *unselectedIndexPaths = [NSMutableArray array];

NSInteger sectionCount = self.tableView.numberOfSections;

for (int i = 0; i < sectionCount; i++) {
    NSInteger rowCount = [self.tableView numberOfRowsInSection:i];

    for (int j = 0; j < rowCount; j++) {
        [unselectedIndexPaths addObject:[NSIndexPath indexPathForRow:j inSection:i]];
    }
}

[unselectedIndexPaths removeObjectsInArray:self.tableView.indexPathsForSelectedRows];
Run Code Online (Sandbox Code Playgroud)