同一视图中有两个SwiftUI选择器的问题

同一视图中有两个SwiftUI选择器的问题,swift,swiftui,picker,Swift,Swiftui,Picker,我对Swift还很陌生,正在尝试学习在私人应用程序上使用SwiftUI 我有一个带有两个SwiftUI选择器的表单,我在模拟器iPhone11中对其进行了测试。构建成功,但每次我选择第二个选择器时,应用程序都会崩溃,并出现错误“Thread 1:EXC_BAD_ACCESS(code=2,address=0x7ffee14e4fe8)” 我的代码是: static let categories = ["a", "b", "c"] static let shops = ["z", "v", "x"

我对Swift还很陌生,正在尝试学习在私人应用程序上使用SwiftUI

我有一个带有两个SwiftUI选择器的表单,我在模拟器iPhone11中对其进行了测试。构建成功,但每次我选择第二个选择器时,应用程序都会崩溃,并出现错误“Thread 1:EXC_BAD_ACCESS(code=2,address=0x7ffee14e4fe8)”

我的代码是:

static let categories = ["a", "b", "c"]
static let shops = ["z", "v", "x", "y"]

@State private var categoryIndex = 0
@State private var shopIndex = 0

var body: some View {
        Form {
            Picker("Category", selection: $categoryIndex) {
                ForEach(0 ..< Self.categories.count) { index in
                    Text(Self.categories[index]).tag(index)
                }
            }
            Picker("Shop", selection: $shopIndex) {
                ForEach(0 ..< Self.shops.count) { index in
                    Text(Self.shops[index]).tag(index)
                }
            }
        }
}
static let categories=[“a”、“b”、“c”]
静态let shops=[“z”、“v”、“x”、“y”]
@国家私有变量类别索引=0
@国家私有var指数=0
var body:一些观点{
形式{
选择器(“类别”,选择:$categoryIndex){
ForEach(0..
我试着给每个拾荒者一个身份证,但是拾荒者不再工作了

有什么想法吗

多谢各位

吉安皮罗