Crash when adding persistent store (iCloud enabled) in app delegate

前端 未结 5 548
南笙
南笙 2020-12-22 18:00

I am going to start updating this to help those seeking to use this as reference for their own personal code.

Newest update

  • I\'m f
5条回答
  •  有刺的猬
    2020-12-22 18:20

    Excuse me Slev, I've got the same problem that you have when you say that the app is crashing because the iCloud data will attempt to merge immediately into the device (where the device has not yet set up its persistent store) but I can't understand how have you solved this.

    Your code is :

    - (void)mergeChangesFrom_iCloud:(NSNotification *)notification {
        if (self.unlocked) {
           NSManagedObjectContext *moc = [self managedObjectContext];
            [moc performBlock:^{
                [self mergeiCloudChanges:notification forContext:moc];
            }];
        }
    }
    

    I haven't tried it yet but looking at this code I wonder what happen to the notifications that arrive when "unlocked" is false. Would you loose them?

    Wouldn't it be better to have a while loop that test the "unlocked" property and spend some timespan until the property becomes true?

    I hope you will understand my very bad english... :) Thank you
    Dave

提交回复
热议问题