ios - Migration fail because Realm accessed before migration -


i using storyboards , of viewcontrollers fetch realm default property values? because of application access realm before application(_:didfinishlaunchingwithoptions:) called. exception raised every time app launches , tries realm migration.

is there way solve issue?

further, since in dev stage , don't want deal migration every time made changes realm object models, there way purge realm file , have fresh start if migration detected needed? find issue reported on github (https://github.com/realm/realm-cocoa/issues/1692) seems no solution provided. ps, using latest realm ios.

if you're unable control order storyboards being loaded automatically ios in contrast app delegate methods, recommendation remove initial storyboard setting app's info.plist file , manually set , display app's delegate instead:

func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool {      let storyboard = uistoryboard(name: "main", bundle: nsbundle.mainbundle())     let initialviewcontroller = storyboard.instantiateinitialviewcontroller()      self.window = uiwindow(frame:uiscreen.mainscreen().bounds)     self.window?.rootviewcontroller = initialviewcontroller     self.window?.makekeyandvisible()      return true } 

this let explicitly control when storyboard loaded, letting after initial realm setup.

if you're tweaking model objects during development , don't need handle migrations yet, 1 possible (but hacky) way of doing call realm() first time, , if throws exception (which if needs perform migration), catch exception , use delete realm file disk.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -