Post

Replies

Boosts

Views

Activity

Reply to Escaping closure captures mutating 'self' parameter Error
I have the same problem and don't understand all hints on the net... My code is: `@Observable struct LADVAthletes { var queryName : String = "" var athletesList : [Athlete] = [Athlete]() var subscription : AnyCancellable? = nil mutating func searchInLADVAthlets() { print("Search in LADV for \(queryName)") let url = URL(string: "https://ladv.de/api/rriekert/athletQuery?query=\(queryName)*&limit=100") subscription = URLSession.shared .dataTaskPublisher(for: url!) .map(\.data) .decode(type: [Athlete].self, decoder: JSONDecoder()) .sink(receiveCompletion: { completion in if case .failure(let err) = completion { print("Retrieving data failed with error \(err)") } }, receiveValue: { object in self.athletesList = object print("Retrieved object \(object)") }) } }` I get the Escaping closure captures mutating 'self' parameter on the receiveValue-phrase.... Any hints?
Jun ’23