1

を使用しNSMetadataQueryてiCloudのファイルを確認しています。ハンドラー内でNSMetadataQueryDidFinishGatheringNotification、アイテムがダウンロードされていない場合、またはダウンロードを使用してダウンロードを開始しますstartDownloadingUbiquitousItemAtURL:fileURL:が、最近、2 つのデバイスでアプリを使用した後、ドキュメントが動かなくなったようです。startDownloadingUbiquitousItemAtURL:fileURL:もうダウンロードを開始しません。

コードの省略形は次のとおりです。

    for (NSMetadataItem * result in query.results)
    {   
        NSURL *fileURL = [result valueForAttribute:NSMetadataItemURLKey];

        // snipped: checks that the item isn't hidden or already downloaded

        if (![fileURL getResourceValue:&isDownloading forKey:NSURLUbiquitousItemIsDownloadingKey error:&error] || !isDownloading)
        {
            NSLog(@"Error %@ getting downloading state for item at %@", error, fileURL);
            continue;
        }

        if ([isDownloading boolValue])
        {
            if (![fileURL getResourceValue:&downloadPercent forKey:NSURLUbiquitousItemPercentDownloadedKey error:&error] || !downloadPercent)
            {
                NSLog(@"Error %@ getting downloaded progress for item at %@", error, fileURL);
                continue;
            }

            NSLog(@"Item at %@ has is %@%% downloaded", fileURL, downloadPercent);
        }
        else
        {
            NSLog(@"Starting to download item at %@", fileURL);

            if ([[NSFileManager defaultManager] startDownloadingUbiquitousItemAtURL:fileURL error:&error])
            {
                isDownloading = nil;

                if ([fileURL getResourceValue:&isDownloading forKey:NSURLUbiquitousItemIsDownloadingKey error:&error] && isDownloading)
                {
                    if ([isDownloading boolValue])
                    {
                        NSLog(@"After starting to download, item at %@ is downloading.", fileURL);
                    }
                    else
                    {
                        NSLog(@"After starting to download, item at %@ is still not downloading!", fileURL);
                    }
                }
                else
                {
                    NSLog(@"Error %@ getting downloading state again for item at %@", error, fileURL);
                }
            }
            else
            {
                NSLog(@"Error %@ starting to download item at %@", error, fileURL);
            }
        }
    }

そして私が見ているのは:

Starting to download item at XXXXXXXX
After starting to download, item at XXXXXXXX is still not downloading!
Starting to download item at YYYYYYYY
After starting to download, item at YYYYYYYY is still not downloading!
Starting to download item at ZZZZZZZZ
After starting to download, item at ZZZZZZZZ is still not downloading!

startDownloadingUbiquitousItemAtURL:fileURL: がアイテムのダウンロードを開始しないのはなぜですか? 何らかの競合が原因である場合、その競合を検出するにはどうすればよいですか?


更新: デバイス コンソールを確認したところ、次のように表示されました。

MyApp[NNNN] <Warning>: Starting to download item at XXXXXXXX
librariand[MMMM] <Error>: unable to download XXXXXXXX (0x8000000000000000)
MyApp[NNNN] <Warning>After starting to download, item at XXXXXXXX is still not downloading!
MyApp[NNNN] <Warning>Starting to download item at YYYYYYYY
librariand[MMMM] <Error>: unable to download YYYYYYYY (0x8000000000000000)
MyApp[NNNN] <Warning>After starting to download, item at YYYYYYYY is still not downloading!
MyApp[NNNN] <Warning>Starting to download item at ZZZZZZZZ
librariand[MMMM] <Error>: unable to download ZZZZZZZZ (0x8000000000000000)
MyApp[NNNN] <Warning>After starting to download, item at ZZZZZZZZ is still not downloading!

そのため、少なくともデーモンはファイルをダウンロードするように指示されているように見えますが、ダウンロードすることはできません。ライブラリアン エラーに関するドキュメントはありますか?

4

1 に答える 1

2

結果を詳しく見てみましょNSMetadataItemNSMetadataQuery。クエリ リクエストの結果を反復処理すると、代わりに次の属性の値を取得できます。

NSString * const NSMetadataUbiquitousItemIsDownloadedKey;
NSString * const NSMetadataUbiquitousItemIsDownloadingKey;
NSString * const NSMetadataUbiquitousItemIsUploadedKey;
NSString * const NSMetadataUbiquitousItemIsUploadingKey;
NSString * const NSMetadataUbiquitousItemPercentDownloadedKey;
NSString * const NSMetadataUbiquitousItemPercentUploadedKey;
于 2012-07-18T20:01:23.167 に答える