UITableView error when deleting row in iphn 2.2 fixed

Discussion in 'iOS Programming' started by mr tickle, May 25, 2009.

  1. mr tickle macrumors newbie

    Joined:
    May 23, 2009
    #1
    Im not sure if this has been mentioned before, but it took me a while to find this, and i didnt locate it on any forums

    when running my application (table view with the option to delete) in iphone 2.2 sim, it would crash out saying that the number of rows should equal the number of rows previously (plus or minus 1).

    i was feeding data from a mutablearray, so it was confusing as hell, and even when i traced out values, it seemed all fine, then, i thought

    what happens if the operation is happening before i delete from the array...

    so i reversed the following

    [tableView deleteRowsAtIndexPaths:[NSMutableArray arrayWithObject:indexPath.......
    [self.myArray removeObjectAtIndex:indexPath.row];

    TO >>>

    [self.myArray removeObjectAtIndex:indexPath.row];
    [tableView deleteRowsAtIndexPaths:[NSMutableArray arrayWithObject:indexPath.......

    and it works

    thus meaning, that the whole reload must have been happening before i had a chance to remove from the array, and checked the total length against its rows, which was not the case in iphone 2.1.

    hope this helps someone. And hope it makes sense
     
  2. mraheel macrumors regular

    Joined:
    Apr 18, 2009
    #2
    Thanks for sharing, these things are kinda tough to figure out given how xcode changes
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    How Xcode changes? What do you mean? :confused:
     

Share This Page