Augustyniak / RATreeView

Library providing easy-to-use interface for displaying tree structures on iOS and tvOS.
MIT License
2.49k stars 465 forks source link

crash in 'cellForItem:item' #84

Closed rp-snt closed 8 years ago

rp-snt commented 9 years ago

I get a crash with this error: * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 10 beyond bounds [0 .. 9]'

fixed it:

 - (UITableViewCell *)cellForItem:(id)item
 {
   NSIndexPath *indexPath = [self indexPathForItem:item];
-  return [self.tableView cellForRowAtIndexPath:indexPath];
+  UITableViewCell *cell = nil;
+  @try {
+    cell = [self.tableView cellForRowAtIndexPath:indexPath];
+  }
+  @catch (NSException *exception) {
+    cell = nil;
+  }
+  return cell;
 }
sadaqata commented 9 years ago

What are you returning for numberOfChildrenOfItem? Also, please post the code for cellForRowAtIndexPath.

rp-snt commented 9 years ago

returned the 2 numberOfChildrenOfItem. CellForRowAtIndexPath of UITableViewDataSource is not implemented .

By the way, I am using the RATreeView from Swift.

Augustyniak commented 8 years ago

@rp-snt Sorry for the really long response time. I added an example project which is entirely written in Swift. It can be found at https://github.com/Augustyniak/RATreeView/tree/master/Examples. Just run example project and select RATreeViewBasicExampleSwift target to run it.

Please take a look at #83 for more details.

I hope that it helps.

Augustyniak commented 8 years ago

Closing. Feel free to reopen if necessary.