Swift - 所需方法未实现:-[JSQMessagesViewController collectionView
Swift - required method not implemented: -[JSQMessagesViewController collectionView
我正在将 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
}
我尝试添加 "override" 但错误消息仍然存在。
有什么解决办法吗?感谢您的帮助!
改变
func collectionView(collectionView: JSQMessagesCollectionView
至
func collectionView(_ collectionView: JSQMessagesCollectionView
我正在将 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
}
我尝试添加 "override" 但错误消息仍然存在。
有什么解决办法吗?感谢您的帮助!
改变
func collectionView(collectionView: JSQMessagesCollectionView
至
func collectionView(_ collectionView: JSQMessagesCollectionView