I'm developing a messaging app (something like WhatsApp), users can send text and image messages to one another.
I created a Message
object, subclass of NSManagedObject
, to store a message details like:
sender_name, timestemp, message_text and message_image (for image messages)
* the average size of an image is like the size of an image taken from the iPhone camera roll library.
First questions is:
Is it a good idea to save the images to Core Data or will it be better to save them to the file system?
The problem is, when I'm in the chat view and I'm scrolling the tableView to see old messages, the scrolling performance get really bad when there are images to load from core data.
I'm using a NSFetchedResultsController
to fetch the messages, and I'm fetching no more then 30 at once. I tried to improve the performance by creating a MessageImage
object, also subclass of NSManagedObject
, to store the UIImage
.
A Message
object has one-to-one relationship with MessageImage
, I did this so when the fetcher loads 30 messages from Core Data, the UIImage itself won't be loaded until requested. But still I get bad performance...
So Second questions is:
What can I do to improve the scrolling performance ?