I’m working with an intermediate join table in Core Data similar to the friends example from Apple’s Core Data Programming Guide. Sorry, can’t post pictures yet due to no reputation points. Its a friends entity with relationships to FriendInfo intermediate join, with relationships of friends and friend info. The following link describes it.
How would I get a list of mutual friends, ie persons both Person A and Person B share as friends? I’m looking to put this into an iPhone application table view.
The answer is almost there in the documentation url you have given. Let’s say there are two people
personAandpersonB. You can get their respective friends byDo a set intersection to find common friends
The set
commonFriendsshould be what you want.Note: The example Apple gives includes an additional property like
befriendedBy. Usually that’s not the case in online social networks such as Facebook where friendship is mutual. But if you were to go down that road and want to count a friendship only when two people are friends of each other, then it’s one extra step to get there. To find the friends of a person in that case, you’d do a set intersection for a person’s friends and those who have befriended him.