I’m currently working on a tableview using MBProgressHUD & NSURLConnection.
The problem is that when a user is at 80th row for example and there are like only 10 rows exist when the table is refreshed with less data, this app totally crashes cuz the row that the user is looking at leads to a released 80th row – bad memory access error.
I’d like to make sure that no matter where the user is at, the app should not crash. What would be the best way to correct this problem? :S
@Bergasms is right, your problem is not related to the table being scrolled, disabling it in this situation is probably unwise (from a design perspective). With that said you can use the
scrollEnabledproperty and set it toNOTo resolve your crash however you should be calling
[self.tableView reloadData]as soon as the datasource is updated.Also your
tableView:numberOfRowsInSection:should return the count from the object backing your datasource.Here is an example implementation that shows updating the datasource while scrolling does not cause a crash if done correctly.
This loads 100 rows into the
stuffsarray onviewDidLoadwhich is immediately scrollable on app launch. After 3 seconds thestuffsarray is emptied and loaded with 10 items, next[self.theTableView reloadData];is called, the interaction is a little jolting but basically the last 90 rows just disappear and all is well, no crash.