The goal of this code below is to filter out dictionaries with a certain ID, where ID is a string.
let dictArray = networkData["dicts"] as! [[String:AnyObject]]
localData["dicts"] = dictArray.filter{ ($0["id"] as! String) != sample.getId() }
This code, however, generates an error:
Cannot invoke 'filter' with an argument list of type '(([String : AnyObject]) throws -> Bool)'
Based on other SO answers like this one and this one, it seems the error is the dictionaries don't conform to Equatable.
So is the only option for using filter to create a custom class to hold the array of dictionaries and make that class conform to Equatable?
If so, perhaps it seems cleaner to simply iterate and create a new array.
filteredData: [String: [[String: AnyObject]]]let id = sample.getId()out of the filter block and use the id instead of.