iphone - Retrieve core-data model version from appDelegate -


anybody knows how core-data model version when app starts?

i've implemented lightweight migration , works fine need check if sqlite db based old model version before migration process starts.

in new model added new entity need populate value of entity of old model. want 1 time.

is there way in appdelegate?

thanks, max

i solved setting db-version in preferences (.plist). if change db, set new db-version in there , store version last start in nsuserdefaults.

nsnumber *newdbversion = [[[nsbundle mainbundle] infodictionary] objectforkey:@"dbversion"]; nsnumber *olddbversion = [[nsuserdefaults standarduserdefaults] objectforkey:@"dbversion"];  if (olddbversion == nil) {     // part without handling, know max db version. }else {     if([olddbversion intvalue] < [newdbversion intvalue])     {         // try liteweight migration , if failed, migrate hand     } } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -