admin管理员组文章数量:1123384
I'm wondering how to solve the Main actor-isolated class property 'current' can not be referenced from a nonisolated context
Swift 6 issue inside a Swift Package.
In this package, I'm exposing a public struct that collects some device information.
Unfortunately, now the UIDevice
class is only accessible as @MainActor
and the information I want to expose should be used even from parallel threads.
All the collected information can be eventually be calculated/collected at the start of the application that uses the package but I'm wondering how to do this properly.
This is a rough example of the current state:
public struct DeviceInfo: Codable, Equatable {
let someVariable: String
public static var current: APIDeviceInfo {
DeviceInfo(
// This is rising the issue `Main actor-isolated class property 'current' can not be referenced from a nonisolated context`
someVariable: UIDevice.current...
)
}
}
My objective is to use this structure even from non-main threads.
本文标签: swiftSolve Main actorisolated static property inside a PackageStack Overflow
版权声明:本文标题:swift - Solve Main actor-isolated static property inside a Package - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736566988a1944719.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论