1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

TableView move and will be crash when reload data ?

Discussion in 'iPhone/iPad Programming' started by anim510, Nov 6, 2008.

  1. macrumors newbie

    #1
    Hi all,

    I use the tableView to show my records, and i use this function to move the rows.
    Code:
    - (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.
    Code:
    [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
     
  2. macrumors 6502a

    #2
    Whats errors are you seeing in the console/debugger when your app crashes?
     
  3. macrumors newbie

    #3
    Error ..

    The error is:

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

    #4
    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.
     
  5. macrumors newbie

    #5
    Thanks buddy!


    Thanks buddy!

    I will be check it.

    Thanks for your suggestion.:)
     

Share This Page