简体   繁体   English

有什么办法可以在核心数据中存储KML文件

[英]Is there any way to store KML file in Core data

Is there any way to store KML file in Core data because i have to send the KML file with some parameters and i have to save KML file along with these Parameters is there any way to store the KML file in Core Data. 有什么方法可以将KML文件存储在Core数据中,因为我必须发送带有某些参数的KML文件,并且我必须将KML文件与这些参数一起保存,因此有任何方法可以将KML文件存储在Core Data中。 Thanks in Advance 提前致谢

There are three possible solutions: 有三种可能的解决方案:

1) Save the files to the file system in the documents directory. 1)将文件保存到documents目录中的文件系统中。 Store the relative path in core data. 将相对路径存储在核心数据中。 Make sure to store the relative path not the absolute path, as the absolute path may change. 确保存储相对路径而不是绝对路径,因为绝对路径可能会更改。 This allows you to store meta data about each file but keep the saving and reading of those file separate from core data 这使您可以存储有关每个文件的元数据,但要使这些文件的保存和读取与核心数据分开

2) Store the files in core data as binary data. 2)将文件存储在核心数据中作为二进制数据。 In your core data model there is an option to set a property as Store in External Record File - you should set it. 在核心数据模型中,有一个选项可以将属性设置为“ Store in External Record File -您应该进行设置。 Also if you don't want to load the file into memory every time you access other meta data that is stored in the Entity then should should store the binary data in a separate entity with a relation to the metadata entity 另外,如果您不想每次访问实体中存储的其他元数据时都将文件加载到内存中,则应将二进制数据存储在与元数据实体相关的单独实体中

3) You can also discard the KML and store all the information in it in core data with custom Entities and objects. 3)您也可以舍弃KML,并使用自定义实体和对象将所有信息存储在核心数据中。 If you want to search or sort KML files based on the data inside of them then you will have to parse them and store at least some of its information in core-data. 如果您要根据KML文件中的数据进行搜索或排序,则必须对其进行解析,并至少将其某些信息存储在核心数据中。 (Perhaps that is what you intended when you said "some parameters"?). (也许这就是您说“某些参数”时想要的?)。 For some application it might be the best approach to parse the entire file and put ALL of the data into core data and the discard the files. 对于某些应用程序来说,解析整个文件并将所有数据放入核心数据并丢弃文件可能是最好的方法。 It depends on your application. 这取决于您的应用程序。

I would recommend approach 1. 我建议方法1。

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

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