如何确保从Swift中获取API的数据

发布于 2025-01-27 19:27:42 字数 1399 浏览 4 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁的年少不轻狂 2025-02-03 19:27:42

总是可以在某些情况下进行提取。当您执行使用数据的函数时,您可以首先确保在操作它之前完全确保有任何数据。
对于慢速互联网,您可以检查“重试”并重试机制:

另外一件事是,UserDefaults不应用于存储大数据,通常用于存储某些用户偏好,例如颜色,字体等(未加密 - 不安全)

There can always be conditions where you can fail a fetch. When you are executing your function that uses the data you were fetching you can first make sure there is any data at all, before manipulating it.
For slow internet specifically, you can check "retries" and retry mechanisms: example

One more thing, UserDefaults shouldn't be used for storing large data, it's typically used for storing some user preferences like colors, fonts, etc. (It's not encrypted - unsafe)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文