In my iOS project, when the user makes a logout I remove the database with the following code:
NSPersistentStore *store = [_persistentStoreCoordinator.persistentStores lastObject];
NSError *error = nil;
NSURL *storeURL = store.URL;
[_persistentStoreCoordinator removePersistentStore:store error:&error];
_persistentStoreCoordinator = nil;
_managedObjectModel = nil;
_managedObjectContext = nil;
[[NSFileManager defaultManager] removeItemAtPath:storeURL.path error:&error];
But after this, if I make a login I keep having the same documents as I used to have even the file has been previously removed. (Notice that the database don't change the name)
In the following link, Delete/Reset all entries in Core Data? One person added the following comment:
Update for iOS5+
With the introduction of external binary storage (allowsExternalBinaryDataStorage or Store in External Record File) in iOS 5 and OS X 10.7, simply deleting files pointed by storeURLs is not enough. You'll leave the external record files behind. Since the naming scheme of these external record files is not public, I don't have a universal solution yet. – an0 May 8 '12 at 23:00
Is already any way to can fix this issue? Thanks
Edit: Don't think it's relevant, but just in case, this are the properties for the class:
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;