我已经声明了String类型的可选属性。在viewDidload中,我调用一个对该属性执行可选绑定的函数:
public var localMsgIdToBeHighlighted: String? = nil
以下是我的方法:
private func performInitialBottomScrolling() {
if let safeLocalMsgId = self.localMsgIdToBeHighlighted, let safeMsgList = self.messageList {
var index = 0
var indexPath: IndexPath? = nil
for msgModel in safeMsgList {
if msgModel.localMsgId == safeLocalMsgId {
indexPath = IndexPath(row: index, section: 0)
break
}
index = index + 1
}
if let safeIndexPath = indexPath {
self.tblViewChatLog.scrollToRow(at: safeIndexPath, at: .bottom, animated: false)
if let cell = self.tblViewChatLog.cellForRow(at: safeIndexPath) {
cell.setHighlighted(true, animated: true)
}
} else {
self.scrollToBottom(animation: false)
}
} else {
self.scrollToBottom(animation: false)
}
}
此崩溃的原因可能是什么?