简体   繁体   English

如何在核心数据中删除插入应用程序中的数据

[英]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.

相关问题 从Core Data Managed Object Context中删除已插入但未保存的对象 - Remove inserted but unsaved object from Core Data Managed Object Context 不将插入的核心数据保存在目标c中 - Not saving inserted core data in objective c 核心数据:何时将NSManagedObject插入上下文并保存? - Core Data: when is NSManagedObject inserted into a context and saved? 如何一次删除许多核心数据对象? - How to remove many core data objects at once? 在将新数据插入核心数据存储区时,如何使UICollectionView始终位于底部 - How to keep UICollectionView always at the bottom while new data is inserted into core data store 如何将核心数据集成到我现有的应用程序中? - How to integrate Core Data to my existing application? 如何从数据数组(核心数据)中删除对象 - How to remove an object from data array (core data) 如何在React Native上删除所有应用程序数据? - How to remove all application data on react native? 如何使用csv文件有效地初始化iOS / Core Data应用程序中的数据? - How to efficiently initialize data in iOS/Core Data application with csv files? 如何在iOS设备上同步应用程序数据和核心数据? - How to sync application data and core data on iOS devices?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM