ARTICLE AD BOX
I'm using Swift 6 and Xcode 26 to develop an exchange monitoring application for macOS. To maintain information from different instruments on an exchange i use following protocols:
protocol DerivativeSymbol { associatedtype Ticker: DerivativeTicker var baseCoin: String {get } var quoteCoin: String {get } var ticker: Ticker? {get set} } protocol DerivativeTicker { var ask1Price: Double { get set } var bid1Price: Double { get set } var ask1Size: Double { get set } var bid1Size: Double { get set } var lastPrice: Double { get set } var indexPrice: Double { get set } }and actor:
actor DerivativeSymbolActor<Symbol: DerivativeSymbol> { var data: [String: Symbol] = [:] var indexPrice: [String: Double] = [:] // ... func updateOptionTicker(symbol: String, ticker: Symbol.Ticker) { data[symbol]?.ticker = ticker } // ... func getAllPairsByBaseAsset(base: String) -> [Symbol] { return data.values.filter({$0.baseCoin == base}) } // ... }In updateOptionTicker function I have warning:
Main actor-isolated property 'ticker' can not be mutated on a nonisolated actor instance
And in getAllPairsByBaseAsset I have another warning:
Main actor-isolated property 'baseCoin' can not be referenced from a nonisolated context
I assume that these warnings are because of default isolation of protocol to MainActor. Is there any solution to mark them as isolated in my actors DerivativeSymbolActor<Symbol: DerivativeSymbol> ?
New contributor
isaharray is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
