PDA

View Full Version : TableView move and will be crash when reload data ?




anim510
Nov 6, 2008, 09:19 PM
Hi all,

I use the tableView to show my records, and i use this function to move the rows.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath

It's will be crash every time when i move the rows, if i call this function.
[myTableView reloadData];

It's will be duplicate if i don't reload data, and it's never be crash.

Has anyone can help me ? Thanks very much. :)

regards,
Neil



jnic
Nov 7, 2008, 04:24 AM
Whats errors are you seeing in the console/debugger when your app crashes?

anim510
Nov 7, 2008, 04:43 AM
Whats errors are you seeing in the console/debugger when your app crashes?

The error is:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray insertObject:atIndex:]: index (3) beyond bounds (1)'

jnic
Nov 7, 2008, 04:53 AM
The error is:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray insertObject:atIndex:]: index (3) beyond bounds (1)'

This means that your data array only contains 1 item, but you're trying to read item 3 (which doesn't exist) and it's causing your app to crash.

You need to check the parts of your code where you add and read data and ensure that you're never reading data before you've added it.

anim510
Nov 7, 2008, 08:30 AM
This means that your data array only contains 1 item, but you're trying to read item 3 (which doesn't exist) and it's causing your app to crash.

You need to check the parts of your code where you add and read data and ensure that you're never reading data before you've added it.


Thanks buddy!

I will be check it.

Thanks for your suggestion.:)