简体   繁体   English

Swift iOS CoreData到闪存驱动器(导出和传输)

[英]Swift iOS CoreData to Flash Drive (Export and Transfer)

I've written an app (to be run on an iPad) that saves entities via CoreData. 我编写了一个应用程序(将在iPad上运行),该应用程序通过CoreData保存实体。 However, it will be used in an environment in which wireless connections may be inhibited and file transfer may need to be done physically. 但是,它将在可能禁止无线连接并且可能需要物理完成文件传输的环境中使用。

Is there any way to export the app's coredata model and saved data entities to a lightning flash drive and then import the data contents onto another iPad running the same app? 有什么方法可以将应用程序的coredata模型和已保存的数据实体导出到闪电驱动器,然后将数据内容导入到运行同一应用程序的另一台iPad上?

Thanks! 谢谢!

It is tricky but possible. 这很棘手,但可能。

  1. Use a SQLite file for your database. 对您的数据库使用一个SQLite文件。 CoreStore provides a simple interface for SQLite. CoreStore为SQLite提供了一个简单的界面。
  2. Get a lightning flash drive with an app that allows receiving and sending arbitrary files from and to other apps. 使用一个应用程序获取闪电闪存驱动器,该应用程序允许与其他应用程序之间收发任意文件。
  3. Send your your SQLite file on iPad A via UIDocumentInteractionController to the lighting flash drive app and store it on the drive. 通过UIDocumentInteractionController将iPad A上的SQLite文件发送到照明闪存驱动器应用程序并将其存储在驱动器上。
  4. Plug the drive into iPad B and send the file from the flash drive app to your own app. 将驱动器插入iPad B,然后将文件从闪存驱动器应用程序发送到您自己的应用程序。
  5. Load the database from the SQLite file. 从SQLite文件加载数据库。

It is not possible (without custom hardware and licenses) to access a lightning flash drive directly, so you need an existing drive with own app to transport the data. 无法(没有自定义硬件和许可证)直接访问闪电闪存驱动器,因此您需要具有自己应用程序的现有驱动器来传输数据。

But why can't you use wireless connections anyway? 但是为什么仍然不能使用无线连接? Even without a cellular network or a WiFi access point you can still communicate via Bluetooth or ad hoc WiFi between the iPads. 即使没有蜂窝网络或WiFi接入点,您仍然可以在iPad之间通过蓝牙或ad hoc WiFi进行通信。

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

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