私は本当に奇妙な問題を抱えています。NSFileManager setUbiquitous 関数を使用すると、ファイルが iCloud にプッシュされますが、1 秒後にこのファイルの存在を確認すると、ファイルはもうありません! iCloud が私のファイルを削除したようですが、それは可能なのでしょうか? またその理由は? 以前にこの問題に遭遇した人はいますか?
static void moveItem( CD_ICloudOperationItem *item, bool toCloud, NSURL *srcDocumentURL, NSURL *srcThumbnailURL, NSURL *dstDocumentURL, NSURL *dstThumbnailURL)
{
dispatch_queue_t mainQueue = dispatch_get_main_queue();
dispatch_queue_t operationQueue = dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 );
dispatch_async(operationQueue, ^(void) {
__block NSError *err1 = nil;
NSFileManager * fm = [ NSFileManager defaultManager];
__block bool success1 = true;
NSString *message = nil;
success1 = [fm setUbiquitous:toCloud itemAtURL:srcDocumentURL destinationURL:dstDocumentURL error:&err1];
bool fileExits = false;
if (toCloud) {
fileExits = [fm isUbiquitousItemAtURL:dstDocumentURL];
if (!fileExits) {
NSLog(@"---> File has NOT been moved correctly!!!! [%@]", dstDocumentURL);
NSLog(@"%@",[err1 description]);
}
else{
NSLog(@"---> File has been moved correctly!!!! [%@]", dstDocumentURL);
}
sleep(1);
fileExits = [fm isUbiquitousItemAtURL:dstDocumentURL];
if (!fileExits) {
NSLog(@"---> After 1 sec file has disappear!!!! [%@]", dstDocumentURL);
NSLog(@"%@",[err1 description]);
}
else{
NSLog(@"---> After 1 sec file still there!!!! [%@]", dstDocumentURL);
}
}
else{
fileExits = [fm fileExistsAtPath:[dstDocumentURL path]];
if (!fileExits) {
NSLog(@"---> File has NOT been moved correctly!!!! [%@]", dstDocumentURL);
NSLog(@"%@",[err1 description]);
}
else{
NSLog(@"---> File has been moved correctly!!!! [%@]", dstDocumentURL);
}
}
if( !success1 )
{
success = false;
message = meaningfulMessageFromError( err1 );
NSLog(@"%@",[err1 description]);
}
dispatch_async( mainQueue, ^(void) {
postNotification( item, success, message );
});
});
}
私の痕跡を見てください:
---> File has been moved correctly!!!! [file://localhost/private/var/mobile/Library/Mobile%20Documents/U5LPYJSPQ3~com~my~container-imobile/Documents/Untitled_(2).fbdi]
---> After 1 sec file has disappear!!!! [file://localhost/private/var/mobile/Library/Mobile%20Documents/U5LPYJSPQ3~com~my~container-imobile/Documents/Untitled_(2).fbdi]