iCloud 저장소를 응용 프로그램 샌드 박스의 로컬 저장소로 마이그레이션하려고했습니다. 코드는 (오류 처리 코드가 명확성을 위해 제거 된) 다음과 같습니다 : 우리가 성공적으로 응용 프로그램 샌드 박스의 새 위치로 아이 클라우드 저장소를 마이그레이션 한이 시점에서iCloud에서 데이터를 삭제하는 방법
NSPersistentStore *iCloudStore = [_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:legacyStoreUrl options:options error:&error];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *targetStoreUrl = [self localStorageUrl];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
nil];
[_persistentStoreCoordinator migratePersistentStore:legacyStore toURL:targetStoreUrl options:options withType:NSSQLiteStoreType error:nil];
하지만, 데이터가 iCloud에 여전히 존재하고 장소에 이전 SQLite는 파일 ... 다음 행은 그래서 내 파일 시스템을 모두 실행 한 후 SQLite는 파일
[fileManager removeItemAtURL:legacyStoreUrl error:nil]
을 삭제하고 지속적인 매장까지 내가 말할 수있는 좋은 찾고 있습니다. 누락 된 점은 iCloud에 저장된 데이터가 iCloud에서 삭제되지 않는다는 것입니다 (앱에서 더 이상 액세스하지 않음). 프로그래밍 방식으로 iCloud 데이터를 삭제하려면 어떻게해야합니까? Apple iCloud 문서에는 거래 로그 삭제에 대한 언급이 있지만 내 문서 폴더에는 정리가 필요한 다른 파일이 표시되지 않습니다. 어떤 도움을 많이 주시면 감사하겠습니다!
업데이트 :
아이 클라우드 저장소가 원래 다음과 같은 옵션을 사용하여 설정 한:
NSURL *ubiquityContainerUrl = [fileManager URLForUbiquityContainerIdentifier:nil];
NSString* coreDataCloudContent = [[ubiquityContainerUrl path] stringByAppendingPathComponent:@"data"];
NSURL *coreDataUrl = [NSURL fileURLWithPath:coreDataCloudContent];
options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
@"MyAppName.store", NSPersistentStoreUbiquitousContentNameKey,
coreDataUrl, NSPersistentStoreUbiquitousContentURLKey,
nil];
답변 해 주셔서 감사합니다. 원래 iCloud 컨테이너를 설정 한 코드가 포함 된 업데이트를 추가했습니다. 안타깝게도 Xcode Organizer를 사용하여 앱 데이터를 기기에서 다운로드하고 "MyAppName.store"또는 "data"를 검색하면 아무것도 발견되지 않지만 데이터는 iCloud에 남아 있습니다. – moliveira
Xcode Organizer를 통해 앱 데이터를 다운로드하여 iCloud 콘텐츠를 볼 수 있을지 의심됩니다. 앱의 iCloud ubiquity 폴더는 파일 시스템의 다른 부분에 보관됩니다. 그것을 얻으려면 developer.icloud.com에 로그온하거나 같은 iCloud 상점에 로그인 한 Mac의'~/Library/Mobile Documents' 폴더를보십시오. 'URLForUbiquityContainerIdentifier : '를 호출하여 얻은 URL은 로컬 장치의 ubiquity 폴더의 루트 위치를 알려줍니다.이 URL을 iCloud의 모든 디버그 덤프를 얻기 위해 다른 대답에서 제공 한 로깅 메서드에 전달합니다. –
위의 코드를 보면, 로그 파일은 iCloud 폴더 내의'/ data'로 해석되는'coreDataUrl' 폴더에있을 것입니다. 이것은'/ Documents'와 같은 레벨에 있습니다. 그래서' * 문서에서 *보십시오. 그러므로 삭제하기 위해서는'coreDataUrl'을 적절한 delete 함수에 전달해야합니다. –