6

新しい iCloud サービスには、多くの構成が可能です。ユーザーのデバイスが、撮影した写真をデバイスに保存するのではなく、iCloud サーバーに送信するように構成されているかどうかを確認するにはどうすればよいですか?

4

2 に答える 2

1

iCloudがアクティブになっているかどうかを知りたい場合は、次の電話をかけるだけです。

 NSFileManager *fileManager = [NSFileManager defaultManager];   
 NSURL *cloudURL = [fileManager URLForUbiquityContainerIdentifier:nil];   
 if (cloudURL != nil) {   
    // iCloud is available
 }

これは、iCloudが利用可能かどうかのヒントを与えることができます。iCloudを使用して写真を保存したい場合は、独自のものを作成できます。あなたが何をしようとしているのかよくわかりません。

于 2011-12-19T12:41:42.940 に答える
1

以下の有効なユビキタス コンテナー識別子を指定する限り、メソッドは次を返す必要がありますYES

static NSString *UbiquityContainerIdentifier = @"ABCDEFGHI0.com.acme.MyApp";

- (BOOL) iCloudIsAvailable
{
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSURL *ubiquityURL = [fileManager URLForUbiquityContainerIdentifier:UbiquityContainerIdentifier];
    return (ubiquityURL) ? YES : NO;
}

URLForUbiquityContainerIdentifier:ただし、セッション内での最初の呼び出しには時間がかかる場合があることがわかりました (数秒)。したがって、これをバックグラウンドで呼び出して、UI を一時的にブロックしないようにしてください。

dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(backgroundQueue,^{
    BOOL isAvailable = [self iCloudIsAvailable]
    /* change to the main queue if you want to do something with the UI. For example: */
    dispatch_async(dispatch_get_main_queue(),^{
        if (!isAvailable){
            /* inform the user */
            UIAlertView *alert = [[UIAlertView alloc] init...]
            [alert show];
            [alert release];
        }
    });
});
于 2012-07-17T09:56:52.630 に答える