I am trying to make a chat app. I have the login and part of the chat interface done, but when I try to configure the chat with the function collectionView(collectionView: JSQMessagesCollectionView!,
messageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageData
, it gives me the error 'Cannot convert return expression of type [JSQMessage] to type JSQMessageData!'
Here is my code for the MessagesViewController :
import UIKit
import JSQMessagesViewController
import Firebase
class MessagesViewController: JSQMessagesViewController {
override func collectionView(collectionView: JSQMessagesCollectionView!,
messageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageData! {
return message[indexPath.item].userMessages
}
override func collectionView(collectionView: UICollectionView,
numberOfItemsInSection section: Int) -> Int {
return message.count
}
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.hidesBackButton = false
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Here is the code for my custom class Messages:
import Foundation
import JSQMessagesViewController
import Firebase
class Messages {
dynamic var user = FIRAuth.auth()?.currentUser?.uid
dynamic var addedUsers = [String]()
dynamic var userMessages = [JSQMessage]()
dynamic var messageDates = [NSDate]()
}
The array messages is var message = [Messages]()
What is my error, Thank You in advance.