0

I'm using the MessageKit for chating when I calling the its delegate and datasource it saying (Cannot find 'messagesCollectionView' in scope) please see the code and guide me thanks.

import UIKit
import FirebaseAuth
import MessageKit

struct Message: MessageType{
    var sender: SenderType
    var messageId: String
    var sentDate: Date
    var kind: MessageKind
}

struct sender: SenderType{
    var photo: String
    var senderId: String
    var displayName: String
}
class ChatDashboard: UIViewController {

    @IBOutlet weak var lblUser: UILabel!
    
    var userActive: String? = nil
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

         messagesCollectionView.messagesDataSource = self
         messagesCollectionView.messagesLayoutDelegate = self
         messagesCollectionView.messagesDisplayDelegate = self //not working delegate and datasource
        if let userData = userActive{
            self.lblUser.text = userData
        }
        
    }
    
    override func viewDidAppear(_ animated: Bool) {
    }

}
Paul Beusterien
  • 27,542
  • 6
  • 83
  • 139
  • 2
    It is right. You don't have a property called `messagesCollectionView` in your view controller – Paulw11 Aug 16 '21 at 21:55
  • yes you're right – King faheem Aug 17 '21 at 12:05
  • Can you please tell me ? How I can get this property properly I've seen tutorials that directly accessing the property without any warning – King faheem Aug 17 '21 at 12:16
  • 1
    Well, in their [quick start guide](https://github.com/MessageKit/MessageKit/blob/master/Documentation/QuickStart.md) they subclass `MessagesViewController`, not `UIViewController` so that is probably a start. – Paulw11 Aug 17 '21 at 12:51

1 Answers1

0

Have a look at their example project usage. Should clear out lots of confusion.

Link: https://github.com/MessageKit/MessageKit/tree/master/Example

As for your query,

Can't find messagesCollectionView because MessagesViewControllerneeds to be extended to access that.

tanmoy
  • 1,276
  • 1
  • 10
  • 28