Instance Property インスタンスプロパティ

ubiquityIdentityToken

An opaque token that represents the current user’s iCloud Drive Documents identity. ある不透明トークン、それは現在のユーザのもつiCloud Drive Documents同一性を表します。

Declaration 宣言

@property(nullable, readonly, copy) id<NSObject, NSCopying, NSCoding> ubiquityIdentityToken;

Discussion 議論

In iCloud Drive Documents, when iCloud is available, this property contains an opaque object representing the identity of the current user. If iCloud is unavailable or there is no logged-in user, the value of this property is nil. Accessing the value of this property is relatively fast, so you can check the value at launch time from your app’s main thread. iCloud Drive Documentsにおいて、iCloudが利用可能である時、このプロパティは現在のユーザの身元を表している不透明オブジェクトを含みます。iCloudが利用可能でないまたはログインしたユーザがいないならば、このプロパティの値はnilです。このプロパティの値にアクセスすることは比較的に高速なので、あなたはこの値をあなたのアプリのメインスレッドから起動時に確認できます。

You can use the token in this property, together with the NSUbiquityIdentityDidChangeNotification notification, to detect when the user logs in or out of iCloud and to detect changes to the active iCloud account. When the user logs in with a different iCloud account, the identity token changes, and the system posts the notification. If you stored or archived the previous token, compare that token to the newly obtained one using the isEqual: method to determine if the users are the same or different. あなたは、このプロパティにおけるトークンを、NSUbiquityIdentityDidChangeNotification通知と一緒に使用して、ユーザがiCloudにログインまたはログアウトする時を検知すること、そしてアクティブなiCloudアカウントに対する変更を検知することができます。ユーザが異なるiCloudアカウントでログインする場合、身元トークンは変化します、そしてシステムは通知を投函します。あなたが以前のトークンを格納またはアーカイブしたならば、そのトークンと新しく得られたものをisEqual:メソッドを使って比較して、ユーザが同じか違うを決定してください。

Accessing the token in this property doesn’t connect your app to its ubiquity containers. To establish access to a ubiquity container, call the URLForUbiquityContainerIdentifier: method. In macOS, you can instead use an NSDocument object, which establishes access automatically. このプロパティの中のトークンにアクセスすることは、あなたのアプリをそれの偏在コンテナに接続しません。ある偏在コンテナへのアクセスを確立するには、URLForUbiquityContainerIdentifier:メソッドを呼び出してください。macOSでは、あなたは代わりにNSDocumentオブジェクトを使用できます、それはアクセスを自動的に確立します。

CloudKit clients should not use this token as a way to identify whether the iCloud account is logged in. Instead, use accountStatusWithCompletionHandler: or fetchUserRecordIDWithCompletionHandler:. CloudKitクライアントは、このトークンを、iCloudアカウントがログインされるかどうか識別する方法として使うべきではありません。代わりに、accountStatusWithCompletionHandler:またはfetchUserRecordIDWithCompletionHandler:を使ってください。

See Also 参照

Managing iCloud-Based Items iCloud基盤の項目を管理する