Search code examples
iphoneioscore-datadatamodel

Suggestions for Implementing an iPhone Chat Application Using Core Data


I am working on an chat app that will use Core Data API.

When user chats, I need to save the chats into the database (Core Data in this case.) Can any one suggest how I can achieve best data management or is there any alternate way to store chat if I don't use Core Data framework?

My specific question is: What strategy should I use to keep track of chats and at the same time avoid any kind of data over load in the database?

I want to save limited chats and when user wants to see old chats, he can send a request to a server which will fill the table with chats using the lazy loading concept of UITableView.

I am looking for some broad guidance.


Solution

  • There is nothing chat app specific in Core Data. Core Data is a data modeling API which means it can model or simulate any type of runtime data an app might need.

    All serious programing starts with the data model. Once the data model is complete, the guts of the app are complete.

    To create a data model, you need to sit down and figure out what your data model will look like in the abstract i.e. don't worry about specifics such as the API or the code just worry about how all the data pieces fit together.

    Think about all the parts and information associated with a chat. For novices, I recommend setting down with a set of index cards. Each card represents an object and you write the objects properties down on the card. Expect to go through a lot of cards.

    Start at the top. Firstly, you have a Chat. Then a Chat as properties like Participants, StartTime,EndTime LineText etc. Participants will have properties like Name, ChatAddress etc.

    Again, the idea is to get an abstract understanding of how all the data needed to model and persist a chat fits together before you start worrying about implementation details. In other words, you want an model so abstract that it could in principle guide the design of a chat written in any language or API. You really need that understanding before you start coding.

    Once you figure out how the data of an abstract chat all fits together, then you can start mapping that to entities and their properties in Core Data. Once you have that done, your app is 50% complete. The rest is just interface.