I am trying compare two arrays. One array is an array of Person
objects, each of which has an email
property that is a String
email address. The other array is an EmailAddress
object which has a descriptive word like "work" or "personal" and the actual String
email address.
Basically both objects have a String
property for email address. I want to compare these arrays of objects to see if one of the objects from each array has the same email address. Right now I am using nested for
loops as shown below but that is taking too long.
for person in self.allPeople! {
for e in EmailAddresses! {
if e.value == person.email {
return true
}
}
}
I thought about using set intersection but that looked like it would only work for comparing the same objects and not object's properties. Thanks.