iCloud 컨테이너에서 내 응용 프로그램의 캐시 디렉토리로 파일을 복사하려고합니다. 계속 The operation couldn’t be completed. (Cocoa error 512.)
을 내 로그에 계속 표시합니다. 이는 매우 광범위한 오류 의미 인 NSFileWriteUnknownError
이거나 쓰기가 실패하고 iOS가 이유를 알지 못합니다.iCloud Cocoa Error 512
다음은 NSMetadataQuery
이 완료되고 iCloud에 파일 이름이있을 때의 코드입니다. 아래 코드를 간단히 설명하겠습니다.
- (void)loadData:(NSMetadataQuery *)query {
NSArray *cache = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[cacheDirectory stringByAppendingString:@"/issues"] error:NULL];
for (NSMetadataItem *item in [query results]) {
NSURL *name = [item valueForAttribute:NSMetadataItemURLKey];
NSString *nameString = [item valueForAttribute:NSMetadataItemPathKey];
NSError *error;
NSURL *cacheURL = [NSURL fileURLWithPath:cacheDirectory];
NSURL *destination = [cacheURL URLByAppendingPathComponent:[NSString stringWithFormat:@"issues/%@", [[nameString stringByDeletingLastPathComponent] lastPathComponent]] isDirectory:YES];
[[NSFileManager defaultManager] copyItemAtURL:[name URLByDeletingLastPathComponent] toURL:destination error:&error];
}
}
}
이 앱은 신문사 문제를 동기화합니다. iCloud 문서 컨테이너에는 데이터가있는 폴더 (한 폴더는 5.1.12
일 수 있음)가 있으며 각 폴더에는 과 동일한 (5.1.12.pdf
)의 PDF 파일이 있습니다.
왜 이런 일이 발생하는지 알고 싶습니다. 당신의 도움을 주셔서 감사합니다.
iCloud: file://localhost/private/var/mobile/Library/Mobile%20Documents/AppBundleID/Documents/5.3.12/
Local: file://localhost/var/mobile/Applications/F91E115B-ECED-403E-AB61-41F7A99EF928/Library/Caches/issues/5.3.12/