0
1

More than 3 years have passed since last update.

iCloud DriveをOn/Offした時の挙動に関して

Posted at

前提

iCloud Driveを使うようにアプリを設計している。

iCloud DriveをOffにする

iOSの設定->アカウント->iCloud->iCloud Driveで一気に、または一覧からアプリ個別に
Offにすると、[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier: <コンテナのID>];がnilを返す。Onならば適切なURLが返ってくる。
例: "file:///private/var/mobile/Library/Mobile%20Documents/iCloud~com~yourdomain~yourapp/" 0x0000000283860310)

アプリのファイルを保存する目的でiCloud Driveを使う場合、nilが返ってきたらfallbackとしてデバイス上に保存するようにしている(Documentsなど)。ややこしいのは、アプリの起動中でもこの設定は変えられてしまう可能性があることかな。適切な挙動としては、アクセスの必要があるたびにnilチェックを行って保存場所を変えるようにする必要があると思う。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1