The question is simple, but I do not know how to correctly implement it.

There is an English-Russian dictionary in which more than 3000 words, the application is only offline. Where do you initially store these words? For example, hardcoding to the class and when you first start to throw the whole thing in CoreData. Or are there other beautiful ways to implement huge dictionaries? Required without internet and download from where either. Everything is local.

  • Zakhardkodit to a file and parse it in CoreData - Vitaly
  • @Vitaly I actually used this method. And there is no more beautiful option? - Alexander Govorukhin

1 answer 1

Save the dictionary in a JSON-file and parse it when downloading the application.

if let path = Bundle.main.path(forResource: "offline_data", ofType: "json") { do { let data = try Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe) let jsonResult = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves) // Your code here } catch { print("error") } }