使用 AppStorage 在 SwiftUI 中持久存储字符串数组

Arn*_*ani 8 arrays swift userdefaults swiftui appstorage

我正在尝试使用 AppStorage 属性包装器在用户默认值中存储字符串数组,如下所示:

@AppStorage("History") var history: [String] = ["End of history"]
Run Code Online (Sandbox Code Playgroud)

但是我得到了错误No exact matches in call to initializer

如果我没记错的话,这是 AppStorage 的限制吗?因为 UserDefaults 可以存储数组?我可以使用什么解决方法?