ios - How to delete group data in Swift? -
i have dictionary , adding tableview.
let myarray = [["name": "first element", "foo": "bar","groupid":"1"], ["name": "first element", "foo": "bar","groupid":"1"],["name": "second element", "foo": "bar","groupid":"2"], ["name": "second element", "foo": "bar","groupid":"2"]]
in dictionary have key groupid
.
is possible can dictionary data groupid = %@
?
i want filter data based on grouping
suppose have 4 data, , group id same in 2 data. want delete data groupid same dictionary.
if groupid == 1
data deleted dictionary groupid == 1
, tableview reload data.
i doing because want delete group data.
you can use filter
on array
remove dictionaries array, check example
var subitems: [[string:string]] = [ ["groupid": "1", "b": "2"], ["groupid": "3", "b": "4"], ["groupid": "1", "b": "6"] ] var filteredsubitems = subitems.filter{ $0["groupid"] != "1" // change groupid } print(filteredsubitems)
Comments
Post a Comment