2013-08-08 3 views
2

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]; 

답변

1

트랜잭션 로그 폴더 당신이 아이 클라우드에있는 저장소를 만들 때에 NSPersistentStoreUbiquitousContentURLKey을 설정 어떤 위치에있을 것이다, 일 수 있습니다. 문서 폴더 외부에 있어야합니다.

developer.icloud.com에 로그온하여 그 시점에 저장된 것이 있는지 확인하십시오.

내가 과거에 사용했던 뭔가를 내 대답 here를 참조 삭제하려면 :

+0

답변 해 주셔서 감사합니다. 원래 iCloud 컨테이너를 설정 한 코드가 포함 된 업데이트를 추가했습니다. 안타깝게도 Xcode Organizer를 사용하여 앱 데이터를 기기에서 다운로드하고 "MyAppName.store"또는 "data"를 검색하면 아무것도 발견되지 않지만 데이터는 iCloud에 남아 있습니다. – moliveira

+0

Xcode Organizer를 통해 앱 데이터를 다운로드하여 iCloud 콘텐츠를 볼 수 있을지 의심됩니다. 앱의 iCloud ubiquity 폴더는 파일 시스템의 다른 부분에 보관됩니다. 그것을 얻으려면 developer.icloud.com에 로그온하거나 같은 iCloud 상점에 로그인 한 Mac의'~/Library/Mobile Documents' 폴더를보십시오. 'URLForUbiquityContainerIdentifier : '를 호출하여 얻은 URL은 로컬 장치의 ubiquity 폴더의 루트 위치를 알려줍니다.이 URL을 iCloud의 모든 디버그 덤프를 얻기 위해 다른 대답에서 제공 한 로깅 메서드에 전달합니다. –

+0

위의 코드를 보면, 로그 파일은 iCloud 폴더 내의'/ data'로 해석되는'coreDataUrl' 폴더에있을 것입니다. 이것은'/ Documents'와 같은 레벨에 있습니다. 그래서' * 문서에서 *보십시오. 그러므로 삭제하기 위해서는'coreDataUrl'을 적절한 delete 함수에 전달해야합니다. –

4

난 그냥 Xcode를 당신이 엑스 코드 메뉴를 사용하여 컨테이너를 재설정 할 수 있다는 것을 발견 :

Debug->iCloud->Delete Container Contents 

그것은 또한 내용을 온라인으로 볼 때 도움이됩니다. https://developer.icloud.com/

관련 문제