Skip to content

Commit

Permalink
Handle nil return from willSelectRowForItem:
Browse files Browse the repository at this point in the history
UITableView allows its matching delegate method to return nil and interprets this as “don’t change the selection”. Returning nil from RATreeViewDelegate doesn’t work the same. A nil return didn’t propagate up as nil, instead being transformed into a re-selection of the current item, with the corresponding delegate calls.
  • Loading branch information
sjmadsen committed Jun 19, 2014
1 parent 2770e0d commit e212e42
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions RATreeView/RATreeView+TableViewDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NS
if ([self.delegate respondsToSelector:@selector(treeView:willSelectRowForItem:treeNodeInfo:)]) {
RATreeNode *treeNode = [self treeNodeForIndex:indexPath.row];
id item = [self.delegate treeView:self willSelectRowForItem:treeNode.item treeNodeInfo:[treeNode treeNodeInfo]];
NSIndexPath *delegateIndexPath = [self indexPathForItem:item];
return delegateIndexPath.row == -1 ? indexPath : delegateIndexPath;
if (item) {
NSIndexPath *delegateIndexPath = [self indexPathForItem:item];
return delegateIndexPath.row == -1 ? indexPath : delegateIndexPath;
} else {
return nil;
}
} else {
return indexPath;
}
Expand Down

0 comments on commit e212e42

Please sign in to comment.