Hi I just want remove repeated objects should be removed in dictionary I am populating it in tableView
Here my sample code in 'CellForRowAtIndexPath'
controller.titleName = dict["itemName"] as? String
my output:
{
itemName = test;
},
{
itemName = funny;
},
{
itemName = vv;
},
{
itemName = hhh;
},
{
itemName = west;
}
First, i think thing you are using array to make dict so before load tableview/collectionview delete all replicated object from your array.
There is one option you have to create NSSet from NSArray so in NSSet all replicated object automatically removed . and then from NSSet you have to create NSArray.
convert set from array as follow
var set = NSSet(array: myarray)
To convert array for set
var newarry = set.allObjects as NSArray
Just try this
let uniqueArr = Array(Set(dict.values))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With