2011-08-12 4 views

답변

30

이 NSSet의 방법 중 발견하기 매우 쉽다.

NSSet *mergedSet = [set setByAddingObjectsFromSet:set]; 

세트 중 하나가 NSMutableSet 후 다음 예에서와 같이 노동 조합 작업을 사용할 수있는 경우는

NSSet *mergedSet = [set setByAddingObjectsFromArray:array]; 
1

당신은이를 사용할 수 있습니다

5

을 사용할 수 있습니다 당신이 다음 설정으로 배열을 병합하는 경우 :

// Create/Get the sets 
NSMutableSet *firstSet = [NSMutableSet setWithArray:@[@"1", @"2"]]; 
NSSet *secondSet = [NSSet setWithArray:@[@"3",@"4"]]; 

// Add missing values from the second set to the first set 
[firstSet unionSet:secondSet]; 
관련 문제