iPhone app launch times and Core Data migration

后端 未结 5 1558
有刺的猬
有刺的猬 2021-02-02 01:51

I have a Core Data application which I plan to update with a new schema. The lightweight migration seems to work, but it takes time proportional to the amount of data in the dat

5条回答
  •  无人共我
    2021-02-02 02:24

    I just found a pretty simple approach. Just wrap all your calls in application:didFinishLaunching with a dispatch_async to the main thread. This will return right away and let you perform your upgrade on the main thread. However, you should probably set your window so that it doesn't display a blank screen while migrating.

    - (void)application:didFinishLaunching {
         dispatch_async(main_queue) {
              // migration
         }
         self.window = ...
         return YES;
    }
    

提交回复
热议问题