Avatar
Avatar
fummicc1
@swift-5.6.3 @swift-5.7.3 import Foundation struct Test { var id: Int var text: String } class Model { @MainActor var list: [Test] = [ Test(id: 1, text: ""), Test(id: 2, text: "") ] init() { Task { let updatedList = [ Test(id: 1, text: "Text1"), Test(id: 2, text: "Text2") ] for updated in updatedList { if let i = await self.list.firstIndex(where: { $0.id == updated.id }) { await MainActor.run(body: { self.list[i].text = updated.text }) } } } } }
exit status: 1 with stderr:<stdin>:23:30: error: actor-isolated property 'list' cannot be passed 'inout' to 'async' function call self.list[i].text = updated.text ^ <stdin>:9:20: note: property declared here @MainActor var list: [Test] = [ ^