Avatar
@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 }) } } } } }