Swift - 未实现的必需方法: - [JSQMessagesViewController collectionView

时间:2017-02-21 16:21:46

标签: ios swift swift3 jsqmessagesviewcontroller

我正在将iOS应用程序迁移到Swift 3,我在ChatViewController上继续出现此错误消息。

2017-02-21 16:40:40.599 Jaco[52613:2864859] *** Assertion failure in -[Jaco.ChatViewController collectionView:messageDataForItemAtIndexPath:], /Users/Royal/dev/jab/ios/Pods/JSQMessagesViewController/JSQMessagesViewController/Controllers/JSQMessagesViewController.m:491
2017-02-21 16:40:40.609 Jaco[52613:2864859] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'ERROR: required method not implemented: -[JSQMessagesViewController collectionView:messageDataForItemAtIndexPath:]'

以下是我的代码的一部分

  // DATA SOURCE 1
  func collectionView(collectionView: JSQMessagesCollectionView!,
                      messageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageData! {
    let data = self.messages[indexPath.item]
    return data
  }


  // DATA SOURCE 2
  override func collectionView(_ collectionView: UICollectionView,
                               numberOfItemsInSection section: Int) -> Int {
    return messages.count
  }

我尝试添加“覆盖”但错误消息仍然存在。

任何想法如何解决这个问题?谢谢你的帮助!

1 个答案:

答案 0 :(得分:1)

更改

func collectionView(collectionView: JSQMessagesCollectionView

func collectionView(_ collectionView: JSQMessagesCollectionView