ios - Core Data Migration: Possible to delete old store except for a few specific objects? -
the new version of our app complete redo, different in every way. reading migration, think i'd fall heavy camp (added relationships), i'm not sure need of data , not sure have chops complex migration. being said, realized users can save favorite stories , i'd preserve of data (but not whole nsmo story entity different now). that's need, few pieces of data few nsmos.
i've got detection setup -isconfiguration:compatiblewithstoremetadata:
, have deleted old store -removeitematurl:
wort case scenario, there way fetch couple things before delete , build new objects?
yes, can stand old store old model , fetch data out of , manually insert new stack. delete old store afterwards. actual workflow be:
- new model separate file
- new store separate file (new file name)
then:
- look old file name on disk. if doesn't exist stand stack
- stand old stack.
- stand new stack.
- copy data old stack new stack.
- save new stack.
- release old stack , delete old store file disk.
no migration needed.
i added old model file. in psc method, detect if compatible , if not, stand old stack, initiating model , psc both pointing old 1 added , creating context. added old class files entity need , fetched favorites , worked! know can create new objects , insert new stack, what's best way save new stack , release old when done? still seem able fetch after removeitematurl. , app delegate best place this?
first, appdelegate not place this. create datacontroller
subclasses nsobject
. put core data code there , pass datacontroller
around.
next, not looking migration state. looking files on disk nsfilemanager
. if old file exists stand old store , new store, copy data over. remove old file.
to release old stack, set references (mom, psc , moc) nil
. arc remove them memory.
Comments
Post a Comment