I have two arrays, which contain objects. Each object has a property "id". If id has the same value - it is duplicates. How can i find and delete duplicates by matching properties ?
Now i use this but sometimes it misses out and writes duplicates into DB
func checkForDupl() {
for var i = 0; i < JSONStorage.count; i++ {
for var b = 0; b < CDStorage.count; b++ {
if JSONStorage[i]!.id == CDStorage[b]!.id {
JSONStorage.removeAtIndex(i)
if JSONStorage.isEmpty {
return
}
}
}
}
}