swift - iOS CoreData commit sub transaction but cancel main transaction -


i have following core data model:

a -> b (1 1)

a -> c (1 n)

i created view controller vc edit properties of instance of a. in vc add possibility create new instances of c user can add new cs on fly if necessary. right doing adding these viewcontext , saving it. works has little hick up. once saved new c context cannot rollback changes have been made previously.

so studied this tutorial , found changes consider separate should applied in own child context. understand still have 1 question: tutorial says changes made childcontext pushed parent on save, never written disk unless save parentcontext. if not want save parent context because user hit cancel button rollback other changes, how can still keep new cs?

don't save data directly managedobject (coredata object) either of entities a, b or c, rather should create model should update according user input or data source. need create managed objects a, b or c , set value respective attributes whenever user confirms save data. means if user hits cancel, data won't saved coredata able find previous data in model throught out model object lifetime.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -