[Solved] Avoid duplicates while adding in dictionary
[ad_1] Try this code to avoid duplication I hope “id” value will be unique in your dictionary. var mydictionary = [“id”: “1”, “quantity”: “”,”sellingPrice”:””] as [String : Any] var arrayOfDictionary = [Dictionary<String, Any>]() //declare this globally let arrValue = arrayOfDictionary.filter{ (($0[“id”]!) as! String).range(of: mydictionary[“id”]! as! String, options: [.diacriticInsensitive, .caseInsensitive]) != nil } if arrValue.count == … Read more