objective c - A good way to serialize changes in object graphs using NSCoding? -


i have graph of objects support nscoding. , have separate class takes care of serialization itself, ie. detects changes in object graph , uses nskeyedarchiver save file.

i’m happy design, i’m not sure how watch changes in object graph. 1 general solution thought of add version property each object gets incremented each change:

- (void) setfoo: (id) newfoo {     _foo = newfoo;     self.version++; } 

when object in graph references other objects, observes version (using kvo) , if changes, change propagated upwards. serialization class observes version of root node.

this works, managing kvo stuff cumbersome , prone errors. can think of a better solution? 1 further constraint objects know little serialization possible. should know how serialize (by implementing nscoding), shouldn’t care more.

this has common problem in serialization frameworks, right?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -