简体   繁体   English

macOS swift - 将数据保存到本地存储 - 最佳实践

[英]macOS swift - save data to local storage - best practices

I'm a newbie in macOS development. 我是macOS开发的新手。 I have an application where I need to save a string (for example a token) to some local storage, and after closing and opening app I want to retrieve this string back. 我有一个应用程序,我需要将一个字符串(例如一个令牌)保存到一些本地存储,并在关闭和打开应用程序后,我想要检索此字符串。

Is it somehow possible that only my app would be able to retrieve this string? 是否有可能只有我的应用程序能够检索此字符串?

Is it better to write it to the txt file or there are some other possibilities? 将它写入txt文件还是有其他可能性更好?

Thank you. 谢谢。

It depends on the security of the data. 这取决于数据的安全性。

  • If security matters save the string in the keychain. 如果安全问题,请将字符串保存在钥匙串中。
  • If security does not matter save the string in UserDefaults 如果安全无关紧要,请在UserDefaults保存字符串

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM