I would like to show loaded image in the cell. I tried to make it in such way:
messages.filter { (mType) -> Bool in
mType.messageId == "\(message.id)"
}.first?.kind = .photo(ImageMediaItem(image: UIImage(systemName: "photo")!.withTintColor(UIColor.gray, renderingMode: .automatic)))
where:
var messages = [MessageType]()
but I saw a message which said:
Cannot assign to property: 'kind' is a get-only property
So I decided to add setter/getter to this property:
struct Message: MessageType {
var sender: SenderType
var messageId: String = ""
var sentDate: Date
var kind: MessageKind{
get {
return self.kind
}
set (newValue) {
self.kind = newValue
}
}
}
I used such scope for adding data to chat list:
messages.append(Message(sender: message.fromId == selectedContactID ? otherSender! : currentUser!, messageId: "\(message.id ?? -1)", sentDate: Date().addingTimeInterval(-8600000), kind: mKind))
but after changes mentioned above I saw such message:
Extra argument 'kind' in call
I tried to look through documentation but I didn't manage to find smth useful for my situation. Maybe someone knows how to solve this problem?
You need to get index of the object you need to change with a
structand for
Extra argument 'kind' in calla computed property shouldn't be in init in addition to that in your case you don't need to make itcomputed propertyas you implement what's already exist by default