5

First of all I'm new in ios/swift...

I need to have offline mode of my app.

I'm using Alamofire for all networking getting json, convert to objects and save into the DB (Core-Data). Wanted to know do I need to have additional cache in between (like: Haneke, or DataCache) in case no internet connection or getting from CoreData?

Is DB request fast/convenient enough?

mihatel
  • 846
  • 14
  • 34

1 Answers1

7

CoreData is very fast (if correctly used). I don't believe it would be necessary to have an additional cache layer.

It would be just a duplication of data that you already have stored in your DB.

By the way all depends from your project use cases. I would not rely on temporary cached data if my app must work without internet connection.

To give you an idea of core data performances so that you can choose what works best for you: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreData/Performance.html

Giuseppe Lanza
  • 3,519
  • 1
  • 18
  • 40
  • thanks for answer: for me still not clear what you mean by very fast, does it mean it is as fast/or faster than cache or ? – mihatel Jan 18 '17 at 12:56
  • 1
    It means that probably you will not feel the difference. By adding an extra layer you will add an overhead. You can measure performances, and you will see some use cases where core data is faster, and some use cases where cache is faster. The problem is that you need to understand what's better for your project. In general, I would prefer to use core data for the reasons explained in my previous answer: no duplication, reliable persistence of data I need for the app to work, easiness to use and no extra layer needed. – Giuseppe Lanza Jan 18 '17 at 13:40