[英]How to remove data inserted in the application in the core data
In Core data , I have prepopulated some data using command line application of Mac. 在Core data中,我已经使用Mac的命令行应用程序预先填充了一些数据。
After that in the application I am storing some additional data .Now the problem is whenever the application terminates the data which is not pre populated and I have stored is still there . 之后,我在应用程序中存储了一些其他数据。现在的问题是,无论何时应用程序终止未预先填充的数据,而我存储的数据仍然在那里。 I want it to be removed [the data which is added in application only not the prepopulated data] . 我希望将其删除[仅将应用程序中添加的数据而不是预先填充的数据]。
can anyone suggest me how can I do it ? 谁能建议我该怎么做?
Sounds like you don't want to ever store data created inside of the application but you always want to revert to the preloaded data. 听起来好像您永远都不想存储在应用程序内部创建的数据,但是您总是想恢复到预加载的数据。 If this is not correct please clarify by updating your question. 如果这不正确,请通过更新您的问题进行澄清。
If that is correct then what I would do is add a second NSPersistentStore
to the NSPersistentStoreCoordinator
. 如果那是正确的,那么我要做的就是将第二个NSPersistentStore
添加到NSPersistentStoreCoordinator
。 The second one would be of type "In Memory". 第二个将是“内存中”类型。 Further, I would change the options on the first store to be read-only. 此外,我会将第一家商店的选项更改为只读。
With these changes the users will add objects and they will go into the in-memory store. 通过这些更改,用户将添加对象,并且它们将进入内存存储中。 When the application quits the in memory store is released and the changes go away. 当应用程序退出时,将释放内存中的存储,并且更改将消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.