要删除的商店,你可以尝试这样的事情:
NSString *docDirPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *storePath = [docDirPath stringByAppendingPathComponent:@"YourDatabaseName.sqlite"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:storePath]) {
[fileManager removeItemAtPath:storePath error:NULL];
并确保您设置persistentStoreCoordinator到零,所以当它被再次访问,它会重新初始化数据库如果您是第一次运行该应用程序。
self.persistentStoreCoordinator = nil;
来源
2010-12-13 09:57:05
Rog
只是可以肯定:你问你如何删除所有对象,之后重新创建它们?既然你说“不包括我如何重现整个事情”。 – 2010-12-13 09:48:57