LoginSignup
7
4

More than 5 years have passed since last update.

UserDefaultsに保存したデータはiTunes/iCoudでバックアップ/復元されるのか?される。

Posted at

記憶が曖昧になっていたので調査しました。

UserDefaultsのドキュメント

まず、UserDefaultsのドキュメントを確認しましたが、こちらには記載させていませんでした。
https://developer.apple.com/documentation/foundation/userdefaults

File Systemのドキュメント

次に、File Systemのドキュメントを確認しました。
https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html

こちらのドキュメントのTable 1-1 Commonly used directories of an iOS appのところにバックアップについて記載があります。

UserDefaultsが保存されているディレクトリ

UserDefaultsに保存したデータがどのディレクトリに保存されているのか、公式ドキュメントを探しましたが見つからず、Qiitaの記事を信用することにしました。
https://qiita.com/dondoko-susumu/items/85f5e1449df94be20fa9

こちらによるとLibraryの下に保存されるようです。

結論

File SystemのドキュメントではLibraryディレクトリはバックアップされると記述されています。

UserDefaultsに保存したデータはLibraryディレクトリの下に保存されるため、バックアップされます。

参考にしたページ

7
4
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
7
4