'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'

瘦欲@ 提交于 2019-12-06 11:04:35

Try adding an all-exception breakpoint (Add Exception Breakpoint) to debug where the exception occures. It does mean you are trying to access an object which is not in the index of array.

Best to find what is causing problem is to raise all exceptions before app crashes.

i

Static cells, I had the same issue. So, I just replaced the tableView content type

"Static cell" to "Dynamic prototypes".

You can make check like this, check for the value before you try to access the index

  if (self.chatSections.count > 0) {
        QMChatSection *currentSection = self.chatSections[indexPath.section];
        if (currentSection.messages.count > 0){
            return currentSection.messages[indexPath.item];
        }else {
            return nil;
        }
    } else {
        return nil;
    }

If you are creating your own code with Quickblox you can refer their demo implementation as for me it works proper

Mr. Bond

try this:

if (item != nil && item.count != 0) {
    QMChatSection *currentSection = self.chatSections[indexPath.section];
    return currentSection.messages[indexPath.item];
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!