开发者

How can I create disposable NSManagedObject objects?

开发者 https://www.devze.com 2023-02-22 23:30 出处:网络
I like using Core Data object modeling, because it gives me generated code and behavior that I like.

I like using Core Data object modeling, because it gives me generated code and behavior that I like.

For example, relationships with the inverse object being updated automatically.

However, for most of my projects I don't need persistent storage. Specifically, I'd like not to save all the objects I created every time I sa开发者_运维知识库ve the context.

What would be a good way to do this?

I thought of using an extra context for disposable objects.


Have you tried creating an in-memory persistent store? When you create a managed object instance, you can assign it to this in-memory store, which will not persist any data to disk, and also is reset on the next launch of your app.

Another way to go is to create a second Managed Object Context, and make sure you never save it.

0

精彩评论

暂无评论...
验证码 换一张
取 消