2

I have created a new data model version and set it to current, then I added a new attribute to an existing Entity. After this when I run the code, it is crashing on the addPersistentStoreWithType and only I can find from the crash is Thread 1: EXC_BAD_ACCESS (code=1, address=0x424531f70)

enter image description here

The below is the code I am getting the crash.

+ (NSPersistentStoreCoordinator *)coordinator:(NSPersistentStoreCoordinator *)coordinator byAddingStoreAtURL:(NSURL *)url configuration:(NSString *)configuration options:(NSDictionary *)options error:(NSError * __autoreleasing*)error {
    if (!coordinator) {
        return nil;
    }
    
    NSError *error1 = nil;
    [coordinator addPersistentStoreWithType:EncryptedStoreType configuration:configuration URL:url options:options error:&error1];
    if (error1) {
        NSLog(@"[ERROR] Problems to initialize persistent store coordinator: %@, %@", error1, [error1 localizedDescription]);
    }
    
    return coordinator;
}

This seems like the crash is occurring on addPersistentStoreWithType enter image description here

This is the stack at the point it crashed: enter image description here

If I delete the newly added attribute, then it runs without any issue with the newly created data model.

Any hints why is it failing? Any idea will be appreciated.

Wide Angle Technology
  • 1,184
  • 1
  • 8
  • 28
  • Could it be the same as this? https://stackoverflow.com/questions/36130416/this-nspersistentstorecoordinator-has-no-persistent-stores-schema-mismatch-or-m – Quack E. Duck Aug 06 '22 at 19:04
  • The question is old, but this recent answer looks like it might possibly solve your problem: https://stackoverflow.com/a/55674642/18248018 – Quack E. Duck Aug 06 '22 at 19:06

0 Answers0