1

I have an NSMutableArray _conversationsArray that basically stores IDs of all the conversations a user has in my app. Based on that value I show different number of rows in the tableView. When I delete a conversation from the data source and trigger reload of the tableView, numberOfRowsInSection method triggers and by setting a breakpoint I check the number of elements (conversations) in that array:

enter image description here

Everything seems to be fine, the result is one object which is great because I had two of them before the deletion. The problem is, as you can see on the far left of the screen, both rows are still visible in the tableView (even after the breakpoint) :/ The second row should have disappeared but it didn't. It did become unresponsive to touch events, but I need it gone.

Have you ever experienced a problem like this? Any help would be greatly appreciated.

--- Update ---

Could it be that it has to do something with the threads? because it seems that the table updates as it should when the thread changes :/ I might be wrong about it as it's hard to debug

budiDino
  • 13,044
  • 8
  • 95
  • 91
  • post the code where you delete the conversation and reload the table – Nick Aug 30 '14 at 21:21
  • This may be a dumb question but I have to ask, has it not deleted because you're sitting at a breakpoint and haven't let the code execute yet? – Mike Aug 30 '14 at 21:29

1 Answers1

2

It looks like you're not reloading the table view on the main thread, since -tableView:numberOfRowsInSection is called on a background thread (?). In UIKit -reloadData must be called on the main thread.

Aderstedt
  • 6,301
  • 5
  • 28
  • 44
  • I was about to answer my own question but I feel a lot better accepting someone else's answer as the correct one ;) Since there are a few methods that actually modify the data source I accidently missed that one of those was called from a background thread so it didn't execute the tableview reload on the main thread. Thanks ;) – budiDino Aug 30 '14 at 21:33