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:
- find simulator file: Sqlite File Location Core Data
- copy this file to Supporting file of your project
- copy that file to Documents directory: iOS ship application with pre populated sqlite database