Im looking for a quick fix to my problems with the iPhone Simulator.
The code I use to access my database is:
+ (NSURL*) databaseURL
{
if(!databaseURL){
databaseURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
databaseURL = [databaseURL URLByAppendingPathComponent:databaseNameString];
}
return databaseURL;
}
+ (UIManagedDocument*) managedDocument
{
if(!managedDocument){
managedDocument = [[UIManagedDocument alloc] initWithFileURL:[FLOWDatabase databaseURL]];
}
return managedDocument;
}
+ (void) initialiseDatabase
{
if ([[NSFileManager defaultManager] fileExistsAtPath:[[FLOWDatabase databaseURL] path]])
[managedDocument openWithCompletionHandler:^(BOOL success) {
//...
}];
else
[managedDocument saveToURL:[FLOWDatabase databaseURL] forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success){
//...
}];
}
The thing is, it works PERFECTLY on the actual iPhone but not on the simulator. The lag time (of 40 seconds) is for initial creation as well as editing an existing file.
I have tried 'reset contents and settings', clean on xcode, delete+rebuild app on the simulator - none of those work.
What to do next?
Vb
I tried reinstalling Xcode and it didn't work.
The solution I have found is to manually delete the persistent store file after every use.
That resolves the problem.