I'm using MVC pattern to deploy iOS application.
When I'm implementing a chat feature like whatsapp I get confused:
The basic idea is that I need to populate the collection view
with all the users present in a firestore collection documents adding a listener to the latest message sent.
the schema for for the collection looks like this:
User_lastMessages (collection)
|
userid (document)
|
ChatUsers (collection)
|
finalDocumentId (document)
This latest document contains:
-user id
-lastMessageSent
-timestampLastMessage
-username
The UI representation I need to accomplish is this one:
1)the username and lastmessage come from the collection I previously mentioned
2)the ImageView (white square) comes from another collection and I can retrieve it through the uid of the user
Question: the number you see on the right side of the cell comes from another collection and it can constantly change. How can I be sure that whenever it changes the UI changes accordingly?
I'm confused whether it's a bad approach to construct a model using different Firestore collection documents or it is mandatory that a model is composed by only one Firestore document.
question from:
https://stackoverflow.com/questions/65862943/construct-model-from-different-collections-firestore-swift-programmatically 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…