No index path for table cell being reused

前端 未结 13 1511
执念已碎
执念已碎 2021-02-04 05:18

This started to happen out of the blue. Any ideas: Code:

CUSTOMCLASSNAME (I have replaced the actual class name as it contains the name of the client.)

Initialis

13条回答
  •  温柔的废话
    2021-02-04 06:14

    Well, I just used the better part of a day trying to figure this out, so hopefully this alternative explanation saves somebody else some time.

    I had a tableview which was giving this message sometimes, when loading. It turned out to be caused by KVO notifications for Core Data objects firing while the view was loading. (On observing a change, my controller tried called reloadData on the tableview in question. Fixed by not observing the objects until the view had finished loading (previously I started observing the object once it was assigned via the accessor)

    TLDR: Check to see if you might be trying to reload your data from something other than the main thread.

    EVEN BETTER:

    This is a problem that you won't run into if you (as I've discovered you really should) use child managed object contexts and only merge changes back into your main MOC on the main thread at sensible times.

提交回复
热议问题