Quote:
Originally Posted by Mick
I am trying to allow the user of my software to empty out an array/UITableview (delete all items in the array and update the tableview that displays the array at the same time). I have managed to empty the array (actually a mutable array) with this:
I know it properly removes everything, because the array gets saved to a propertylist/file when the application closes, and upon reloading I can see the data was in fact deleted. However, the application crashes (sooner or later - doesn't always happen right away) if I try to scroll the tableview after emptying it, and I'm sure this is because I am not updating the tableview properly after emptying the array. I think I need to use a line like this:
to update the tableview, but I really don't understand how to use this method. I think I understand what an indexPath is, but how do I set up an array of them to make sure all data is deleted?
|
That is most likely not your problem.
If you remove the contents of the array you use as data source you would probably call [myTableView reloadData]. This causes the table view to ask for how many rows there are now (0). So it will just draw a blank table.
The method you mention is good for animating the removal of single rows. So the pattern usually is: remove from NSArray, then make the table animate the removal.
I suspect your problem is that you are accessing memory that was previously released.
__________________
regards
Oliver Drobnik
Cocoanetics - Our DNA is programmed in Objective-C.
Linguan – makes localizing strings file fun!
Cocoanetics Parts Store – easy to use yet professionally looking components that you can use to spruce up your own apps. Augmented Reality, Calendar Control, Pin Lock or Purchase Button are only some examples. You get full source code, no static library crap, and lifetime support. Check it out today!