Core Data entities missing when tested on device

2019-09-14 01:59发布

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条回答
Deceive 欺骗
2楼-- · 2019-09-14 02:12

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
查看更多
登录 后发表回答