gpt4 book ai didi

iOS - 同步保存到 UserDefaults 吗?

转载 作者:搜寻专家 更新时间:2023-11-01 06:01:08 25 4
gpt4 key购买 nike

UserDefaults 上的操作是同步的吗?例如,第二次保存是否等待第一次保存完成?

UserDefaults.standard.set(myValue1, forKey: "myValue1")
UserDefaults.standard.set(myValue2, forKey: "myValue2")

最佳答案

来自苹果的documentation :

At runtime, you use UserDefaults objects to read the defaults that your app uses from a user’s defaults database. UserDefaults caches the information to avoid having to open the user’s defaults database each time you need a default value. When you set a default value, it’s changed synchronously within your process, and asynchronously to persistent storage and other processes.

关于iOS - 同步保存到 UserDefaults 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50206997/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com