class 属性 的结构是线程安全的吗?

Is struct with class property a thread safe?

据我所知structs是线程安全的。但是当它有 class 属性 时它仍然是线程安全的吗?

struct UserLocation {
    let geocoder = CLGeocoder()
}

我问这个是因为我目前正在调试指向我们的结构对象的随机崩溃。我们的结构对象正在多线程中传递。

由于代码的所有权,我无法 post 此处提供确切的代码,因此我创建了一小段代码。

根据 OP 的要求,他将接受此评论作为答复。

well no matter what inside the struct, its value driven that what makes it thread safe, therefore a class instance inside it is totally fine because you are passing a new value of it, however i am not 100% sure i would suggest to make property as ( lazy var )