启动时在 Core Data 中预填信息. [英] Prefill information in Core Data at startup.

查看:18
本文介绍了启动时在 Core Data 中预填信息.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须做一个使用核心数据来存储信息的 iOS 应用程序.

I have to do an iOS application that used core data to store the information.

我创建了模型以及如何将数据添加到应用程序中,一切正常,唯一的问题是数据模型是空的,但我想在应用程序启动时自动填充一些数据.

I created the model and how to add data into the application, everything is working perfect, the only problem I have is that, the data model is empty, but I wanted to fill automatically with some data when the application is startup.

我该怎么办?

推荐答案

查看一些示例应用,例如 iPhone 核心数据手册.基本上,您随应用程序一起提供预填充的数据库,并在初始启动时,您的应用程序委托使用您在数据库中填充的数据将其复制到应用程序的 Documents 目录中.

Take a look at some of the sample apps, like the iPhone Core Data Books. Basically you ship a pre-filled database with your app, and on initial startup your app delegate copies it into the application's Documents directory, using the data you populated in the database.

这篇关于启动时在 Core Data 中预填信息.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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