Reputation: 1901
Right now i am using coredata to save my data. Its all working fine but now i changed the logic to save values to the database. So i need to compare that the after logic change same values are getting saved in tables. So I need to compare tables.
I went through many links like link 1 link 2
all the links shows that the database file that coredata create is of .sqlite extension. But the files create at that location are "persistentStore, persistentStore-shm, persistentStore-wal" as show in screenshot.
How should i suppose to open these files to see the saved data in tables. Thanks in advance
- (void)setupDatabase:(void (^)(BOOL))completionHandler
{
NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
url = [url URLByAppendingPathComponent:@"MainDataModel"];
self.db = [[CWUIManagedDocument alloc] initWithFileURL:url];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
self.db.persistentStoreOptions = options;
if(![[NSFileManager defaultManager] fileExistsAtPath:[self.db.fileURL path]])
{
[self.db saveToURL:self.db.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
self.dataManager.db = self.db;
completionHandler(success);
}];
} else if (self.db.documentState == UIDocumentStateClosed) {
[self.db openWithCompletionHandler:^(BOOL success) {
self.dataManager.db = self.db;
completionHandler(success);
}];
}
}
Upvotes: 0
Views: 839
Reputation: 39988
Run these commands on terminal and open yourpersistentStore
in sqlite manager. These commands will merge the WAL file into the main sqlite file
$ sqlite3 persistentStore
sqlite> PRAGMA wal_checkpoint;
Press control + d
These steps are already covered in the answer of the above link : https://stackoverflow.com/a/43406516/468724
Upvotes: 1
Reputation: 4375
In setupDatabase()
method replace the following line
url = [url URLByAppendingPathComponent:@"MainDataModel"]
with
url = [url URLByAppendingPathComponent:@"MainDataModel.sqlite"]
You have to create the persistent store type as Sqlite
Upvotes: 1
Reputation: 1996
Your sql file is the one without extension. The other 2 files are for journaling mode.
This has already been explained in this question. Apple changed the default journaling mode to WAL on iOS 7.
Upvotes: 1