Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when accessing index path row #4

Closed
eytanbiala opened this issue Sep 19, 2014 · 1 comment
Closed

Exception when accessing index path row #4

eytanbiala opened this issue Sep 19, 2014 · 1 comment

Comments

@eytanbiala
Copy link

Hey,

Thanks again for creating this, it's been very helpful.

I have some code to collapse all the currently expanded cells in the table:

    for (NSIndexPath *indexPath in self.expandedItems.allKeys) {
        NSIndexPath *treeIndexPath = [self.tableView treeIndexPathFromTablePath:indexPath];
        [self.expandedItems removeObjectForKey:treeIndexPath];
        [self.tableView collapse:treeIndexPath];
    }

In - (NSIndexPath *)treeIndexPathFromTablePath:(NSIndexPath *)indexPath, the app crashes at
`NSUInteger row = indexPath.row;```, with this exception:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid index path for use with UITableView.  Index paths passed to table view must contain exactly two indices specifying the section and row.  Please use the category on NSIndexPath in UITableView.h if possible.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010c3bf3f5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010c040bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010c3bf25a +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x000000010bc5e28f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
    4   UIKit                               0x000000010ac3f6d9 -[NSIndexPath(UITableView) row] + 175
    5   TreeViewExample                     0x000000010a3a525c -[UITableView(TreeTable) treeIndexPathFromTablePath:] + 92
    6   TreeViewExample                     0x000000010a3a15b9 -[DAViewController collapse] + 521
    7   Foundation                          0x000000010bbfafd4 __NSFireTimer + 83
    8   CoreFoundation                      0x000000010c3274e4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    9   CoreFoundation                      0x000000010c3270a5 __CFRunLoopDoTimer + 1045
    10  CoreFoundation                      0x000000010c2ea3dd __CFRunLoopRun + 1901
    11  CoreFoundation                      0x000000010c2e9a06 CFRunLoopRunSpecific + 470
    12  GraphicsServices                    0x000000010edf99f0 GSEventRunModal + 161
    13  UIKit                               0x000000010a8fe550 UIApplicationMain + 1282
    14  TreeViewExample                     0x000000010a3a1063 main + 115
    15  libdyld.dylib                       0x000000010c9ec145 start + 1
    16  ???                                 0x0000000000000001 0x0 + 1
)

It seems to only happen when the depth of the expanded items is > 1.

@eytanbiala
Copy link
Author

Oops, the keys in expandedItems are already converted paths:

    for (NSIndexPath *treeIndexPath in self.expandedItems.allKeys) {
        self.treeModel.closingAnimation = UITableViewRowAnimationNone;
        [self.expandedItems removeObjectForKey:treeIndexPath];
        [self.tableView collapse:treeIndexPath];
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant