iOS 5 Core Data freeze

前端 未结 7 917
清歌不尽
清歌不尽 2021-01-30 22:48

I try to do the following simple thing:

NSArray * entities = [context executeFetchRequest:inFetchRequest error:&fetchError];

Nothing fancy.

7条回答
  •  旧巷少年郎
    2021-01-30 23:31

    Delete all object with fetchrequest doesn't work for me, the sqlite looks corrupted. the only way I found is

        //Erase the persistent store from coordinator and also file manager.
        NSPersistentStore *store = [self.persistentStoreCoordinator.persistentStores lastObject];
        NSError *error = nil;
        NSURL *storeURL = store.URL;
        [self.persistentStoreCoordinator removePersistentStore:store error:&error];
        [[NSFileManager defaultManager] removeItemAtURL:storeURL error:&error];
    
        //Make new persistent store for future saves   (Taken From Above Answer)
        if (![self.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
            // do something with the error
        }
    

提交回复
热议问题