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)
发布评论
评论(1)
总是可以在某些情况下进行提取。当您执行使用数据的函数时,您可以首先确保在操作它之前完全确保有任何数据。
对于慢速互联网,您可以检查“重试”并重试机制:
另外一件事是,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)