I am using the latest version of the MessageKit for the practice, and I am getting this error of "'SenderType' cannot be constructed because it has no accessible initializers" during compilation,
why it happened and please recommend the solution as well
thank you
import Foundation
import UIKit
import MessageKit
struct Member {
let name: String
let color: UIColor
}
struct Message {
let member: Member
let text: String
let messageId: String
}
extension Message: MessageType {
**//ERROR IS SHOWN HERE**
var sender: SenderType {
return SenderType(id: member.name, displayName: member.name)
}
/* var sender: Sender {
return Sender(id: member.name, displayName: member.name)
}*/
var sentDate: Date {
return Date()
}
var kind: MessageKind {
return .text(text)
}
}
Well Protocol is just a blueprint, not a fully fledged Type (sometimes called as Existential Type).
But, whoever adopts & conforms to it is actually a Concrete Type and that Class/Struct/Enum can/should be instantiated.
Reference: https://docs.swift.org/swift-book/LanguageGuide/Protocols.html