I'm sending only items with isSelected = true into favCountries.
There are all the countries that came from the service in countries.
I want to compare the countries coming from the service with favCountries and make isSelected = true in the countries array for countries with the same code and the values that are isSelected = true in favCountries.
If the code in the favCountries array and the code in the countries array match, I want to make the item value in the countries array isSelected = true
I am using this model.
public struct CountryData: Codable {
public let code: String?
public let currencyCodes: [String]?
public let name: String?
public let wikiDataID: String?
public var isSelected: Bool = false
}
var favCountries: [CountryData]
var countries: [CountryData]
let favCountries = countries.filter(\.isSelected)