EditActionsForRowAt is not getting called properly when voice control is enabled

140 views Asked by At

If voice control is on, in addition to swipe the cell, EditActionsForRowAt will be called as well when we scroll the tableview or load the cell. And If I scroll table view fast, it will crash on the EditActionsForRowAt delegate function with the message:

Invalid index path for use with UITableView. Index paths passed to table view must contain exactly two indices specifying the section and row. Please use the category on NSIndexPath in NSIndexPath+UIKitAdditions.h if possible

It seems like the indexPath will not be passed properly somewhere. Sometimes indexPath will be empty in that case. When the crash happens, indexPath will not be nil but contain nothing.

(lldb) po indexPath.isEmpty
true
(lldb) po indexPath == nil
false

I resolve this crash by adding code in function editActionsForRowAt:


guard !indexPath.isEmpty else { return [] }

However, the EditActionsForRowAt function is not supposed to be called when I scroll the table view. Does anyone have an idea about this? How may I prevent EditActionsForRowAt to get called from when we load the cell if voice-control is on?

0

There are 0 answers