I have this array:
class Filter {
var key = ""
var value = ""
init(key: String, value: String) {
self.key = key
self.value = value
}
}
let arry = [
"a":[Filter(key:"city",value:"aachen"),Filter(key:"city",value:"augsburg")],
"b":[Filter(key:"city",value:"bremen"),Filter(key:"city",value:"berlin")]
]
and I want to look for augsburg and remove it from the dictionary with the filter function so the output looks like this:
let arry = [
"a":[Filter(key:"city",value:"aachen")],
"b":[Filter(key:"city",value:"bremen"),Filter(key:"city",value:"berlin")]
]
I tried it with many filter and map constelations but I always get this structure as result:
let arry = [
["a":[Filter(key:"city",value:"aachen")]],
["b":[Filter(key:"city",value:"bremen"),Filter(key:"city",value:"berlin")]]
]
for example with this filter:
arry.map({ key,values in
return [key:values.filter{$0.value != "augsburg"}]
})
What is the problem here? How can I filter and map over more complex objects?