Guest User

Untitled

a guest
Jun 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. NSArray* set1 = [NSArray arrayWithObjects:@"one",@"two",@"three",nil];
  2. NSArray* set2 = [NSArray arrayWithObjects:@"two",@"three",@"four",nil];
  3.  
  4. NSMutableArray* set3 = [NSMutableArray arrayWithCapacity:MIN(set1.count,set2.count)];
  5.  
  6. for (NSString* element in set1) {
  7. if( [set2 containsObject:element] ) {
  8. [set3 addObject:element];
  9. }
  10. }
  11.  
  12. // set3 => [ @"two", @"three" ]
Add Comment
Please, Sign In to add comment