Core Data entities missing when tested on device

不羁的心 提交于 2020-02-07 19:52:52

问题


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.


回答1:


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. 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


来源:https://stackoverflow.com/questions/42226590/core-data-entities-missing-when-tested-on-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!