Nick Kohrn
Nick Kohrn

Reputation: 6049

How to Make iOS App Heavy in Network Requests Feel Responsive

I am working on an application that is socially-based. It mainly deals with creating schedules for a specific activity and inviting other users to join on a specific date and time. However, the application is using Parse as its backend. Almost every action taken requires some networking, and it can feel slow on a low-quality connection.

How can I make the application seem more responsive?

  1. When data is retrieved, say a list of current friends, do I store those friends in Core Data, and then update my Core Data model by adding or removing friends during a refresh?
  2. Should I use some sort of caching tool, such as NSCache?
  3. Do I just present a loader on the screen while the the network requests are running and then update the UI when finished?

I see that applications such as Facebook and Instagram present a few posts when the applications are launched while they go fetch the latest data, but I'm not sure as to how they accomplish this.

Can you provide me with an appropriate direction to take?

Upvotes: 0

Views: 76

Answers (1)

Tom Harrington
Tom Harrington

Reputation: 70956

Keeping some kind of offline cache is useful, since it means you'll have some data to display immediately even if you're still loading new data from a network connection. Core Data can be useful for this, but it really depends on the nature of the data and on how your app uses it. NSCache probably isn't what you want, since it only keeps data in memory and doesn't save it for the next time your app runs.

Apps that need frequent network updates (like Facebook) commonly make use of iOS's background fetch system. If you opt in to this, iOS will launch your app in the background from time to time to allow it to get new data. If your app saves that data somewhere on the device, it's already present when the user taps your app icon.

Using background fetch is pretty easy-- you add the appropriate key to Info.plist, and then implement application(application:, performFetchWithCompletionHandler:) in your app delegate.

Upvotes: 1

Related Questions