Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个数组。Array1 包含 15 个对象,Array2 包含 4 个对象。两个数组都有 2 个公共对象,我只想得到这 2 个对象的结果数组。
它应该像两个 Set 的交集,但是如何在 Objective C 中为数组..?请帮忙。谢谢。
使用 NSMutableSet
NSMutableSet *set1 = [NSMutableSet setWithArray: array1]; NSSet *set2 = [NSSet setWithArray: array2]; [set1 intersectSet: set2]; NSArray *resultArray = [set1 allObjects];