Im trying to avoid duplicates in my object array tat returns from core-data, by using an extension. But it gives me the error saying "cannot convert the value type of ()-> to expected argument type [Object type]->()". my code as bellow. What am i missing.
viewDidLoad (){
// get the above mentioned error here
let uniqueArray = myArray.unique{$0.Id}
}
extension Array {
func unique<T:Hashable>(map: ((Element) -> (T))) -> [Element] {
var set = Set<T>() /
var arrayOrdered = [Element]()
for value in self {
if !set.contains(map(value)) {
set.insert(map(value))
arrayOrdered.append(value)
}
}
return arrayOrdered
}
}