What the best way to store messages with image locally

Hi everyone,


I'm developping an iOS applicaiton which user can have private chat with other users.

Actually when a user received a message I create a new "Message" object which containt: FromId, ToId, Message, Image, date

I add the message to my existing array of message like this MyExistingMessage.add(Message)

Finally I save the array on the iPhone memory using UserDefault with the uniqueId of the other user.


Here a representation of what i have on the memory of the iPhone after multiple discutions.


DiscutionXinMemory[[Message], [Message], [Message]]

DiscutionYinMemory[[Message], [Message], [Message]]


This solution is not optimized because it's take time to load the message and if I save too much image it's may crash the application.


So I have think to create a local database to save my message but I want an external review before rewriting this part of my code.


Is a local database appropriate to save text and image ?


I hope you will understand me (English is not my mother tongue)


Thank you

What the best way to store messages with image locally
 
 
Q