전 아이폰 개발에 뛰어 들고 있습니다. 어리숙한 질문이라면 사과드립니다.하지만 Core Data 프레임 워크를 사용하는 새로운 iPad 앱 프로젝트에서는 persistentStoreCoordinator를 생성하기 위해 생성 된 코드가 여기에 있습니다 ...iPhone 앱의 핵심 데이터 영구 저장소는 어디에서 찾을 수 있습니까?
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator != nil) {
return persistentStoreCoordinator;
}
NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"ApplicationName.sqlite"]];
NSError *error = nil;
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&error]) {
/*
Replace this implementation with code to handle the error appropriately.
abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
Typical reasons for an error here include:
* The persistent store is not accessible
* The schema for the persistent store is incompatible with current managed object model
Check the error message to determine what the actual problem was.
*/
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return persistentStoreCoordinator;
}
내 질문은 ...
- 내가 응용 프로그램을 처음 실행하면, 존재하지 않는 경우 자동으로 생성 된 ApplicationName.sqllite 데이터베이스가 무엇입니까? 그렇지 않다면 언제 만들어 집니까? 프로그래밍 방식으로 데이터를 추가 할 때?
- DB가 존재하면 어디에서 파일을 찾을 수 있습니까? 다른 프로그램으로 열어서 수동으로 데이터를 조작 할 수 있습니다.
도움을 위해 미리 감사드립니다. 지금 당장이 문제를 계속 연구 할 것입니다.
감사합니다. Brad, 하루 종일 큰 도움이되었습니다. – BeachRunnerFred