macOS swift-将数据保存到本地存储-最佳做法 [英] macOS swift - save data to local storage - best practices

查看:106
本文介绍了macOS swift-将数据保存到本地存储-最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是macOS开发的新手.我有一个应用程序,需要在其中将字符串(例如令牌)保存到一些本地存储中,并且在关闭和打开应用程序后,我想找回该字符串.

I'm a newbie in macOS development. 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?

将其写入 txt 文件还是更好的选择?

Is it better to write it to the txt file or there are some other possibilities?

谢谢.

推荐答案

这取决于数据的安全性.

It depends on the security of the data.

  • 如果安全性很重要,则将字符串保存在钥匙串中.
  • 如果安全性无关紧要,则将字符串保存在 UserDefaults

这篇关于macOS swift-将数据保存到本地存储-最佳做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆