简体   繁体   English

如何将大量数据加载到CoreData中

[英]How to load large amount of data into CoreData

I have a CoreData database that gets initialized with a local file. 我有一个使用本地文件初始化的CoreData数据库。
The CoreData schema that looks like this: CoreData架构如下所示:

Category -->> Objections -->> Responses -->> Evidence  

("-->>" means, has many) (“ - >>”表示有很多)

Each entity also has a description that can be anywhere from 2 to thousands of characters long, stored in an NSString. 每个实体还有一个描述,可以是2到数千个字符长,存储在NSString中。

Question: How can I store this data so that it would be easy for someone to edit without having to know a lot about programming? 问题:如何存储这些数据,以便人们在不必了解编程的情况下轻松编辑? (But also follow best practices) (但也遵循最佳做法)

Currently, I am thinking of these as possible approaches: 目前,我认为这些是可能的方法:

1) Store everything in 1 big plist file. 1)将所有内容存储在一个大的plist文件中。 This would be about 25 pages long. 这将是大约25页长。
2) Separate each entity into it's own PList file, and relate each the values with an ID#, like a Relational Data Base. 2)将每个实体分成它自己的PList文件,并将每个值与ID#相关联,如关系数据库。 This would make the files a more manageable size, but you have to keep track of ID#. 这将使文件的大小更易于管理,但您必须跟踪ID#。
3) Same as above, but with JSON 3)与上面相同,但使用JSON

Create a dead simple desktop application that uses Core Data. 创建一个使用Core Data的死简单桌面应用程序。 Let the people edit the file in that desktop application and keep it stored in Core Data. 让人们编辑该桌面应用程序中的文件并将其存储在Core Data中。 Then when you ship your application you can embed that SQLite file into your iOS application so there is no start up parsing required. 然后,当您发送应用程序时,可以将该SQLite文件嵌入到iOS应用程序中,这样就不需要启动解析。

Standing up an OS X app for this that doesn't need to be pretty is dead simple. 站在一个OS X应用程序,这不需要漂亮是很简单的。 Takes an afternoon or two at most and saves you a ton of headaches. 最多花一两个下午,为您节省大量的麻烦。

run in simulator, do the parsing of the plist OR CSV (might be easier, since thats an excel compatible format) there (in the simulated app) and then copy the resulting DB to your xcode project and ship it. 在模拟器中运行,解析plist或CSV(可能更容易,因为那是一个excel兼容的格式) 那里 (在模拟的应用程序中)然后将生成的数据库复制到你的xcode项目并运送它。

=> your 'content provider' can work with excel =>您的'内容提供商'可以使用excel

=> you don't have to ship a CSV (or whatever file you use) since you have a filled DB after you parsed it in the simulator =>您不必发送CSV(或您使用的任何文件),因为在模拟器中解析后,您有一个填充的数据库

There is a nice post from Mattt Thompson about Core Data Libraries & Utilities: http://nshipster.com/core-data-libraries-and-utilities/ , maybe something fit for you. Mattt Thompson有一篇关于Core Data Libraries&Utilities的文章: http ://nshipster.com/core-data-libraries-and-utilities/,也许适合你。 =] =]

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

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