在设备上测试时缺少核心数据实体 [英] Core Data entities missing when tested on device

查看:97
本文介绍了在设备上测试时缺少核心数据实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Xcode / swift制作一个简单的应用程序。使用模拟器时,我能够在核心数据中保存和检索数据,但是当我使用实际的iPhone设备测试该应用程序时,我的现有数据丢失了。我不知道为什么会这样,怎么办。我是iOS开发的新手,在此先感谢您。

I am trying to make a simple app using Xcode/swift. I am able to save and retrieve data in core data when using the simulator, however when I tested the app using an actual iPhone device my existing data are missing. i don't know why this is, and what to do about it. I am new in iOS development, thanks in advance.

推荐答案

这是预期的行为,因为您需要将数据存储在模拟器内存​​中Mac,则应将该数据库文件从模拟器复制到应用程序主捆绑包中的Supporting Files中,然后复制到真实设备中应用程序的Documents目录中。
这样的步骤:

This is expected behavior, because youк needed data stored in simulator memory on the mac, and you should copy that database file from simulator to Supporting Files in main bundle of your app and then copy to Documents directory of your app in real device. So steps:


  1. 查找模拟器文件:
    sqlite文件位置核心数据

  2. 将此文件复制到项目的支持文件

  3. 将该文件复制到文档目录:带有预先填充的sqlite数据库的iOS船运应用程序

  1. find simulator file: Sqlite File Location Core Data
  2. copy this file to Supporting file of your project
  3. copy that file to Documents directory: iOS ship application with pre populated sqlite database

这篇关于在设备上测试时缺少核心数据实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆