Właśnie zacząłem używać danych podstawowych. Chcę skonfigurować wstępnie wypełniony db. Czytałem gdzieś, że dane podstawowe tworzy plik sqlite, gdy uruchamiana jest podstawowa aplikacja danych. Nie wiem, gdzie go szukać.XCode4 - gdzie szukać pliku sqlite utworzonego przez podstawowe dane
Postępowałem zgodnie z instrukcjami na tym blog, ale nie znalazłem pliku sqlite w lokalizacji określonej katalogu /Users/<Username>/Library/Application Support/iPhone Simulator/User/Application/<Application GUID>/Documents/<database name.sqlite>
ani w katalogu aplikacji.
Oto mój kod dla persistentCoordinator.
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (__persistentStoreCoordinator != nil)
{
return __persistentStoreCoordinator;
}
NSString *storePath = [[[self applicationDocumentsDirectory] path] stringByAppendingPathComponent:@"coredata.sqlite"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:storePath]) {
NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"coredata" ofType:@"sqlite"];
if (defaultStorePath) {
[fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL];
}
}
NSURL *storeURL = [NSURL fileURLWithPath:storePath];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
NSError *error = nil;
__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error])
{
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return __persistentStoreCoordinator;
}
Jak poznać ** GUID aplikacji **? –