Best data persistence practice

Asked

Viewed 375 times

2

When it comes to persisting the data with the Core Data. What is the best way to persist the data?

For example:

I own an object Pessoa (subclass of NSObject). And at the time of persistence I "convert" the PessoaMO (subclass of NSManagedObject).

What I wanted to know is basically the following:

The correct way to do this, is like the example quoted above or directly with the NSManagedObject without having the class Pessoa (subclass of NSObject)?

  • 3

    http://meta.pt.stackoverflow.com/a/1911/101

  • You only need the class that derives from Nsmanagedobject. Whatever you touch it will automatically be saved. Unless you really need a temporary copy of the object to work with for a while without saving, which is not common.

1 answer

1

This solution seems to disrespect the DRY (Don’t Repeat Yourself) because in addition to a duplication in the code the classes Personal and Person will be dependent. (Any change in one breaks the other).

A solution would be several user with Nsmanagedobjectcontext’s to make a better control of what will be persisted and what will be discarded. (I believe that’s what you’re doing).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.