Search code examples
social-networkingbackend

Best approach for easliy loading data from back end server for iOS application


We are developing a social networking iOS application. The application loads lots of data from back end server. I have following doubts which is still unclear .Please help

  1. What is the best approach for handling these much data from back end server?.
  2. How does social networking mobile applications like facebook loads and update friends data?
  3. Does these kind of application uses a local database to store these data?? If so when is the values in the local database updated?
  4. Is making an synchronous call on a separate thread same as making an asynchronous server call?

Please provide your suggestions.Thanks in advance


Solution

    1. Ideally, load data "on demand". Request from the server the data the user is seeing at the moment, or that you think she will see soon. Also, request data in batches (for example, last 50 posts, or post between certain dates).
    2. Considering the answer above, Facebook does something similar. The key is to be smart on the server side. Let the client ask for a feed, for example. The server returns the last 50 posts and a "next page" attribute. The client can store that attribute and when the user scrolls down to the last post, send a request to the server asking for more news and passing the "next page" attribute that the server previously returned. The server of course will return a new "next page" with the new request. In this way, what is returned to the client is decided by the server.
    3. Yes, you should use a local database which acts like a client cache. This is used to present the data that was shown to the user the last time she opened the app, so that you can show something while the request is loading from the server. You should update your database when the server sends a response to your request. This is also valid for friend lists, messages, etc. Don't forget, though, that the server has he most up-to-date information and the client database is mostly a cache to display temporary information.
    4. Not exactly the same but for your use case it will be very similar. Ideally some operating systems provide low level asynchronous network operations, which is much better than handling it on your code with a background thread.