UIManagedDocument
및 그 기능에 대해 배우기 시작했습니다. 내가 아는 바로는 데이터베이스의 한 형태가 문서 디렉토리의 한 위치에 저장되어 있습니다.NSPersistentStoreCoordinator가 UIManagedDocument에 생성되지 않았습니다
어쨌든, 나는 UIManagedDocument
를 만들고 컨텍스트에 데이터를 저장하는 몇 초 후에, 그러나 그 NSManagedObjectContext
내에서 데이터를 저장하여 데이터베이스로 사용하려고 해요 (I가 시간 초과 같은데요 후) 앱이 다운되고 지속적인 스토어 코디네이터가 없다고 알려줍니다.
관리되는 문서를 만든 후 영구 저장소 조정자를 만드는 방법에 대한 Apple 문서에 대한 많은 지침은없는 것처럼 보입니다.
정확히 어떻게합니까?
감사합니다.
편집
코드 내가 사용 :
NSURL *url = [[self iCloudDocumentsURL] URLByAppendingPathComponent:nameOfDocument];
NSMutableArray *books = [self.books mutableCopy];
[books addObject:url];
[self setBooks:books];
UIManagedDocument *document = [[UIManagedDocument alloc] initWithFileURL:url];
NSDictionary *options = @{ NSMigratePersistentStoresAutomaticallyOption : @YES,
NSInferMappingModelAutomaticallyOption : @YES,
NSPersistentStoreUbiquitousContentNameKey : document.fileURL.lastPathComponent,
NSPersistentStoreUbiquitousContentURLKey : [self iCloudCoreDataLogFilesURL] };
[document setPersistentStoreOptions:options];
if (document.documentState == UIDocumentStateClosed) {
[document openWithCompletionHandler:^(BOOL success) {
Book *book = [Book newBookWithTitle:bookTitle
inManagedObjectContext:document.managedObjectContext];
[document updateChangeCount:UIDocumentChangeDone];
}];
}
업데이트 백그라운드 스레드에서이 코드를 수행 한 후. 내 응용 프로그램은 문서를 연 후 완료 핸들러의 성공 여부를 'NO'로 기록합니다.
이2013-04-23 00:01:08.381 Notable[193:4b0b] -[_PFUbiquityRecordsImporter rollResponseOperation:encounteredAnError:whileTryingToAdoptBaseline:](1545): CoreData: Ubiquity: <PFUbiquityBaselineRollResponseOperation: 0x1fa561d0> localPeerID: mobile.2DDB96C5-A317-5BE5-8F29-9F5E6681A27A, storeName: A-B893A0AB-B764-42F1-9402-38790DCEF96B, modelVersionHash: NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=
ubiquityRootLocation: <PFUbiquityLocation: 0x1e59b790>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs
Encountered an error while trying to respond to the roll of baseline: <PFUbiquityBaseline: 0x1e54deb0>(0)
permanentLocation: <PFUbiquityLocation: 0x1f8e7120>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip
safeLocation: <PFUbiquityLocation: 0x1f8eb1b0>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/mobile.2DDB96C5-A317-5BE5-8F29-9F5E6681A27A
currentLocation: <PFUbiquityLocation: 0x1f8e7120>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip
storeName: A-B893A0AB-B764-42F1-9402-38790DCEF96B
modelVersionHash: NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=
baselineArchiveLocation: <PFUbiquityLocation: 0x1f8e7120>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip
Error: Error Domain=NSCocoaErrorDomain Code=134310 "The operation couldn’t be completed. (Cocoa error 134310.)" UserInfo=0x1f8d2ae0 {baseline=<PFUbiquityBaseline: 0x1e54deb0>(0)
permanentLocation: <PFUbiquityLocation: 0x1f8e7120>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip
safeLocation: <PFUbiquityLocation: 0x1f8eb1b0>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/mobile.2DDB96C5-A317-5BE5-8F29-9F5E6681A27A
currentLocation: <PFUbiquityLocation: 0x1f8e7120>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip
storeName: A-B893A0AB-B764-42F1-9402-38790DCEF96B
modelVersionHash: NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=
baselineArchiveLocation: <PFUbiquityLocation: 0x1f8e7120>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip
, localStoreKV=<PFUbiquityKnowledgeVector: 0x1f8220c0>()}
userInfo: {
baseline = "<PFUbiquityBaseline: 0x1e54deb0>(0)\n\tpermanentLocation: <PFUbiquityLocation: 0x1f8e7120>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip\n\tsafeLocation: <PFUbiquityLocation: 0x1f8eb1b0>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/mobile.2DDB96C5-A317-5BE5-8F29-9F5E6681A27A\n\tcurrentLocation: <PFUbiquityLocation: 0x1f8e7120>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip\n\n\tstoreName: A-B893A0AB-B764-42F1-9402-38790DCEF96B\n\tmodelVersionHash: NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=\n\tbaselineArchiveLocation: <PFUbiquityLocation: 0x1f8e7120>: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip\n";
localStoreKV = "<PFUbiquityKnowledgeVector: 0x1f8220c0>()";
}
이 방법은 또한 내가에서 언급 한 CS193P 비디오에서 언급이 파일에 따라 필요가 믿는 'DocumentMetaData.plist을'(작성 : 그러나, 내 응용 프로그램이 충돌하지 않는 대신에 나는 다음과 같은 로그를 얻을 수 'persistentStore'라는 파일 대신 주석 (comment)을 사용합니다.
코어 데이터에 대한 일반적인 설명으로, 데이터베이스로 생각하면 장기적으로는 어려움을 겪을 것입니다. 핵심 데이터는 데이터베이스가 아닌 지속성 프레임 워크입니다. 어느 정도까지는 데이터베이스처럼 작동하지만 Core Data == 데이터베이스 사고 방식에서 접근하면 뒤에서 당신을 물들이는 미묘한 차이가 있습니다. – theMikeSwan
그래, Core Data가 데이터베이스가 아니라는 것을 알았습니다. (위에서 말했듯이) UIManagedDocument를 데이터베이스로 생각하기가 더 쉬웠습니다 (어쨌든 만들 어 응용 프로그램 용). –
걱정하지 말고 그냥 길을 가려하지 말고 다른 사람들이 내려 가서 길 아래로 싫어하는 것을 보았습니다. – theMikeSwan