简体   繁体   English

在 iOS 应用程序中存储大量 static 信息的最佳方式?

[英]Best way to store a large amount of static information in an iOS app?

If I have a large amount of information that will be randomly used while the app is being used, what is the best way to store and access that data?如果我有大量信息会在使用应用程序时被随机使用,那么存储和访问这些数据的最佳方式是什么?

The app completely relies on the static text that I have and will need to grab certain parts and concatenate them depending on what the user selects within the app.该应用程序完全依赖于我拥有的 static 文本,并且需要根据用户在应用程序中选择的内容来抓取某些部分并将它们连接起来。

Is it best to load it into Core Data when the app loads the first time and then check if it is loaded every time after that?最好在应用程序第一次加载时将其加载到 Core Data 中,然后检查是否每次都加载它? If so, how?如果是这样,怎么做?

Core Data's primary focus is not persisting data but instead on managing a complex graph of objects that contain and manipulate data. Core Data 的主要关注点不是持久化数据,而是管理包含和操作数据的复杂对象图。 The API is intended to create the entire model layer of a Model-View-Design application. API 旨在创建模型-视图-设计应用程序的整个 model 层。

If you have a lot of chunks of text all that need separate logic or if your app will create those chunks out of a large body of text, then core data is a good choice.如果你有很多需要单独逻辑的文本块,或者如果你的应用程序会从大量文本中创建这些块,那么核心数据是一个不错的选择。

If you just have something like a very basic text editor then probably not.如果您只有一个非常基本的文本编辑器,那么可能没有。

Core Data is completely inappropriate for your use case. Core Data 完全不适合您的用例。

Store your text in a .strings file and use NSLocalizedString() to access it.将您的文本存储在.strings文件中并使用NSLocalizedString()来访问它。 This will provide a convenient way to lookup text by key and make localization simple.这将提供一种方便的方式来按键查找文本并使本地化变得简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM